首页 文章 精选 留言 我的

精选列表

搜索[传媒云原生 移动开发平台],共10000篇文章
优秀的个人博客,低调大师

ecshop后台订单自动确认开发详解

image CREATE TABLE `order_auto_confirm` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `order_id` INT(10) UNSIGNED NOT NULL DEFAULT '0', `order_sn` VARCHAR(20) NOT NULL, `execute_time` INT(10) UNSIGNED NOT NULL DEFAULT '0', `order_status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0未确定,1已经确定', `addtime` INT(10) UNSIGNED NOT NULL DEFAULT '0', `update_time` INT(10) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE INDEX `order_id` (`order_id`), INDEX `execute_time` (`execute_time`) ) COMMENT='订单定期自动确定' COLLATE='utf8_general_ci' ENGINE=MyISAM; 一、 /admin/order.php加入以下代码: elseif($_REQUEST['act'] == 'order_cron') { $act1 = empty($_POST['act1']) ? 0 : $_POST['act1']; if(empty($act1) || !in_array($act1, array('add', 'cancel'))) make_json_response('', -1, '未知请求act1'); $order_id = intval($_POST['order_id']); $order = order_info($order_id); if(empty($order)) make_json_response('', -2, '没有此订单ID'); if($order['order_status']) make_json_response('', -3, '此订单已经确认,不用自动确认'); if($order['pay_status']) make_json_response('', -4, '此订单支付状态已经变动,无法添加任务'); if($act1 == 'add'){ $order_cron_time = empty($_POST['order_cron_time']) ? 0 : $_POST['order_cron_time']; if(empty($order_cron_time)) make_json_response('', -10, '请求的时间错误'); $sql = 'select order_id from '.$ecs->table('order_auto_confirm').' where order_id='.$order_id; $rs = $db->getRow($sql); if($rs['order_id'] == $order_id){ make_json_response('', -30, '此订单任务已经存在,不能重复添加'); } $execute_time = local_strtotime($order_cron_time); $sql = "insert into ".$ecs->table('order_auto_confirm')."(order_id, order_sn, execute_time, order_status, addtime) values(".$order_id.",'".$order['order_sn']."',".$execute_time.", 0, ".local_gettime().")"; $result = $db->query($sql); if($result){ make_json_response('', 0, ''); } make_json_response('', -9, '添加任务计划失败'); }elseif($act1 == 'cancel'){ $sql = 'delete from '.$ecs->table('order_auto_confirm').' where order_id='.$order_id.' and order_status=0 '; $db->query($sql); make_json_response('', 0, ''); } } 二、 在elseif($_REQUEST['act'] == 'info')里加入: //取自动确定订单信息 $sql = 'select order_status, execute_time, addtime, update_time from '.$ecs->table('order_auto_confirm').' where order_id='.$order['order_id']; $cron= $db->getRow($sql); if(!empty($cron)){ if($cron['order_status'] == 1) $cron['update_time'] = sprintf($_LANG['order_auto_croned'], local_date('Y-m-d H:i:s', $cron['update_time'])); else $cron['execute_time']= sprintf($_LANG['order_auto_cron'], local_date('Y-m-d H:i:s', $cron['execute_time'])); } $smarty->assign('cron', $cron); 三、 /includes/modules/cron/order_auto_confirm.php if (!defined('IN_ECS')) { die('Hacking attempt'); } require_once(ROOT_PATH . 'includes/lib_order.php'); $cron_lang = ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/cron/order_auto_confirm.php'; if (file_exists($cron_lang)) { global $_LANG; include_once($cron_lang); }/* 模块的基本信息 */ if (isset($set_modules) && $set_modules == TRUE) { $i = isset($modules) ? count($modules) : 0; /* 代码 */ $modules[$i]['code'] = basename(__FILE__, '.php'); /* 描述对应的语言项 */ $modules[$i]['desc'] = 'order_auto_confirm_desc'; /* 作者 */ $modules[$i]['author'] = 'wjzhhr'; /* 网址 */ $modules[$i]['website'] = 'http://www.wodeqingchun.com'; /* 版本号 */ $modules[$i]['version'] = '1.0.0'; /* 配置信息 */ $modules[$i]['config'] = array( array('name' => 'order_auto_confirm_count', 'type' => 'select', 'value' => '10'), ); return; } $time = gmtime(); //$time = local_gettime(); $limit = empty($cron['order_auto_confirm_count']) ? 5 : $cron['order_auto_confirm_count']; $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('order_auto_confirm') . " WHERE execute_time <= ".$time." and order_status=0 LIMIT $limit"; $autodb= $db->getAll($sql); $i = 0; foreach ($autodb as $key => $val) { $order_id = $val['order_id']; $order_sn = $val['order_sn']; /* 标记订单为已确认 */ $update_status = update_order($order_id, array('order_status' => OS_CONFIRMED, 'confirm_time' => gmtime())); update_order_amount($order_id); /* 记录log */ $action_note = "计划任务:定期自动确定订单,订单号:".$order_sn.",执行状态:".($update_status ? '成功' : '失败'); order_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, PS_UNPAYED, $action_note, 'system_cron'); /* 如果原来状态不是“未确认”,且使用库存,且下订单时减库存,则减少库存 */ if ($val['order_status'] != OS_UNCONFIRMED && $_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE) { change_order_goods_storage($order_id, true, SDT_PLACE); } if($update_status) { $i += 1; $sql = "update " . $GLOBALS['ecs']->table('order_auto_confirm') . " set order_status=1, update_time=".$time." where order_id=".$order_id; $db->query($sql); } }$string = '此次共更新:'.$i.'条数据'; echo $string;file_put_contents('./a.txt', $time . '----' . date('Y-m-d H:i:s').$string."\r\n", FILE_APPEND); /** * 更新订单总金额 * @param int $order_id 订单id * @return bool //zuimoban.com */ function update_order_amount($order_id) { include_once(ROOT_PATH . 'includes/lib_order.php'); //更新订单总金额 $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET order_amount = " . order_due_field() . " WHERE order_id = '$order_id' LIMIT 1"; return $GLOBALS['db']->query($sql); } ?> 四、 /languages/zh_cn/admin/order.php里加入: // $_LANG['order_auto_croned'] = '此订单于 %s 已被确认'; $_LANG['order_auto_cron'] = '此订单于 %s 进行定时确认'; $_LANG['order_auto'] = '将此订单加入自动定时确认'; $_LANG['order_auto_time'] = '自动确认时间:'; 五、 /admin/themes/order_info.htm在:{$lang.base_info}后面加入: image 在此页面的JS里面加入: function order_cron(order_id, act){ var order_cron_time = 0; if(act == 'add'){ order_cron_time = document.getElementById('order_cron_time').value; if(!order_cron_time){ alert('无法获取时间'); return false; } } Ajax.call('order.php?act=order_cron', 'order_id=' + order_id + '&act1=' + act + '&order_cron_time=' + order_cron_time, order_cron_response, 'POST', 'JSON');}function order_cron_response(res){ if (res.error == 0) { alert('保存成功'); } else { alert(res.message); } return false;} 还有/themes/default/footer.dwt里是否含有:{insert name='query_info'} 这一句,比较重要,前人把这句去掉了,害最模板到处找原因。共涉及5个文件,两个新添加的 我只是个搬运工。侵删。原文:httpwww.ktshou.comportal.phpmod=view&aid=121

优秀的个人博客,低调大师

iOS开发之缓存(一):内存缓存

前面一片文章介绍了如何上传和下载文件,这篇文章将介绍一下如何在iOS设备中进行缓存。 这篇文章将只介绍一下将内容缓存到内存中,下一篇文章就介绍一下在iOS磁盘上缓存内容。 使用缓存的目的是为了使用的应用程序能更快速的响应用户输入,是程序高效的运行。有时候我们需要将远程web服务器获取的数据缓存起来,减少对同一个url多次请求。 内存缓存我们可以使用sdk中的NSURLCache类。NSURLRequest需要一个缓存参数来说明它请求的url何如缓存数据的,我们先看下它的CachePolicy类型。 1、NSURLRequestUseProtocolCachePolicy NSURLRequest默认的cache policy,使用Protocol协议定义。 2、NSURLRequestReloadIgnoringCacheData 忽略缓存直接从原始地址下载。 3、NSURLRequestReturnCacheDataElseLoad 只有在cache中不存在data时才从原始地址下载。 4、NSURLRequestReturnCacheDataDontLoad 只使用cache数据,如果不存在cache,请求失败;用于没有建立网络连接离线模式; 5、NSURLRequestReloadIgnoringLocalAndRemoteCacheData:忽略本地和远程的缓存数据,直接从原始地址下载,与NSURLRequestReloadIgnoringCacheData类似。 6NSURLRequestReloadRevalidatingCacheData:验证本地数据与远程数据是否相同,如果不同则下载远程数据,否则使用本地数据。 NSURLCache还提供了很多方法,来方便我们实现应用程序的缓存机制。下面我通过一个例子来说明,这个例子减少我们对同一个url多次请求。看下面代码: -( IBAction ) buttonPress:( id ) sender { NSString *paramURLAsString= @ "http://www.baidu.com/" ; if ([paramURLAsString length] == 0){ NSLog (@ "Nil or empty URL is given" ); return ; } NSURLCache *urlCache = [ NSURLCache sharedURLCache]; /* 设置缓存的大小为1M*/ [urlCache setMemoryCapacity:1*1024*1024]; //创建一个nsurl NSURL *url = [ NSURL URLWithString:paramURLAsString]; //创建一个请求 NSMutableURLRequest *request = [ NSMutableURLRequest requestWithURL:url cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0f]; //从请求中获取缓存输出 NSCachedURLResponse *response = [urlCache cachedResponseForRequest:request]; //判断是否有缓存 if (response != nil ){ NSLog (@ "如果有缓存输出,从缓存中获取数据" ); [request setCachePolicy: NSURLRequestReturnCacheDataDontLoad ]; } self .connection = nil ; /* 创建NSURLConnection*/ NSURLConnection *newConnection = [[ NSURLConnection alloc] initWithRequest:request delegate: self startImmediately: YES ]; self .connection = newConnection; [newConnection release]; } 这个例子中,我们请求url为www.baidu.com的网站。如果这个url被缓存了,我们直接从缓存中获取数据,否则从www.baidu.com站点上重新获取数据。我们设置了缓存大小为1M。 使用下面代码,我将请求的过程打印出来: - ( void ) connection:( NSURLConnection *)connection didReceiveResponse:( NSURLResponse *)response{ NSLog (@ "将接收输出" ); } - ( NSURLRequest *)connection:( NSURLConnection *)connection willSendRequest:( NSURLRequest *)request redirectResponse:( NSURLResponse *)redirectResponse{ NSLog (@ "即将发送请求" ); return (request); } - ( void )connection:( NSURLConnection *)connection didReceiveData:( NSData *)data{ NSLog (@ "接受数据" ); NSLog (@ "数据长度为 = %lu" , (unsigned long )[data length]); } - ( NSCachedURLResponse *)connection:( NSURLConnection *)connection willCacheResponse:( NSCachedURLResponse *)cachedResponse{ NSLog (@ "将缓存输出" ); return (cachedResponse); } - ( void )connectionDidFinishLoading:( NSURLConnection *)connection{ NSLog (@ "请求完成" ); } - ( void )connection:( NSURLConnection *)connection didFailWithError:( NSError *)error{ NSLog (@ "请求失败" ); } 当我们第一次点击界面上的按钮,打印的结果如下: 2011-07-30 18:50:24.910 Caching[3971:207] 即将发送请求 2011-07-30 18:50:28.557 Caching[3971:207] 将接收输出 2011-07-30 18:50:31.677 Caching[3971:207] 接受数据 2011-07-30 18:50:31.681 Caching[3971:207] 数据长度为 = 4414 2011-07-30 18:50:31.682 Caching[3971:207] 接受数据 2011-07-30 18:50:31.682 Caching[3971:207] 数据长度为 = 2996 2011-07-30 18:50:38.107 Caching[3971:207] 将缓存输出 2011-07-30 18:50:38.109 Caching[3971:207] 请求完成 在看我们第二次点击界面上的按钮,打印结果如下: 2011-07-30 18:52:18.894 Caching[3971:207] 即将发送请求 2011-07-30 18:52:18.895 Caching[3971:207] 将接收输出 2011-07-30 18:52:18.895 Caching[3971:207] 接受数据 2011-07-30 18:52:18.896 Caching[3971:207] 数据长度为 = 7410 2011-07-30 18:52:18.896 Caching[3971:207] 请求完成 我们看到没有“将缓存输出”一项,请求到的数据是第一次请求的累积,也就是第二次是从内存中获取数据的。 总结:本文简单的介绍了一下iOS的内存缓存机制,下一篇文章将重点介绍一下本地缓存机制。 本文转自麒麟博客园博客,原文链接:http://www.cnblogs.com/zhuqil/archive/2011/07/30/2122127.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS开发之自定义View

iOS sdk中的view是UIView,我们可以很方便的自定义一个View。 创建一个 Window-based Application程序,在其中添加一个Hypnosister的类,这个类选择继承UIObject。修改这个类,使他继承:UIView @interface HypnosisView :UIView 自定义View的关键是定义drawRect: 方法,因为主要是通过重载这个方法,来改变view的外观。例如,可以使用下面代码绘制一个很多环中环的效果的view。 View Code 这样view的效果如下图: 我们可以继续绘制一些东西,比如绘制文字,将下面代码添加带这个方法后面。 // Create a string NSString *text =@"我是朱祁林,不是朱麒麟";// Get a font to draw it in UIFont *font = [UIFont boldSystemFontOfSize:28];// Where am I going to draw it? CGRect textRect; textRect.size = [text sizeWithFont:font]; textRect.origin.x = center.x - textRect.size.width /2.0; textRect.origin.y = center.y - textRect.size.height /2.0;// Set the fill color of the current context to black [[UIColor blackColor] setFill];// Set the shadow to be offset 4 points right, 3 points down, // dark gray and with a blur radius of 2 points CGSize offset = CGSizeMake(4, 3); CGColorRef color = [[UIColor darkGrayColor] CGColor]; CGContextSetShadowWithColor(context, offset, 2.0, color);// Draw the string [text drawInRect:textRect withFont:font]; 效果: 如果view过大,我们可以把它放置到一个UIScrollView中间,这样就可以进行拖动了。UIScrollView与View的关系如下图: 使用下面代码创建一个比iPhone屏幕大4倍的View,然后通过UIScrollView来展示,代码如下: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {//创建一个窗体大小的CGRect CGRect wholeWindow = [[self window] bounds];// 创建一个窗体大小的HypnosisView实例 view = [[HypnosisView alloc] initWithFrame:wholeWindow]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:wholeWindow]; [[self window] addSubview:scrollView];// Make your view twice as large as the window CGRect reallyBigRect; reallyBigRect.origin = CGPointZero; reallyBigRect.size.width = wholeWindow.size.width *2.0; reallyBigRect.size.height = wholeWindow.size.height *2.0; [scrollView setContentSize:reallyBigRect.size]; CGPoint offset; offset.x = wholeWindow.size.width *0.5; offset.y = wholeWindow.size.height *0.5; [scrollView setContentOffset:offset];// Create the view view = [[HypnosisView alloc] initWithFrame:reallyBigRect]; [view setBackgroundColor:[UIColor clearColor]]; [scrollView addSubview:view]; [scrollView release]; [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; [[self window] makeKeyAndVisible];return YES; } 这样我们就可以拖动来展示看不到的view了,如下图: 通过UIScrollView我们还可以设置view的缩放功能,将下面代码添加到中。这样我们就可以使用两根手指缩放view了。 // Enable zooming [scrollView setMinimumZoomScale:0.5]; [scrollView setMaximumZoomScale:5]; [scrollView setDelegate:self]; 总结:文本简单的总结了一下自定义view的使用。 代码:Hypnosister.zip 本文转自麒麟博客园博客,原文链接:http://www.cnblogs.com/zhuqil/archive/2011/07/27/2118843.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS开发之详解剪贴板

概述: 在iOS中,可以使用剪贴板实现应用程序之中以及应用程序之间实现数据的共享。比如你可以从iPhone QQ复制一个url,然后粘贴到safari浏览器中查看这个链接的内容。 一、在iOS中下面三个控件,自身就有复制-粘贴的功能: 1、UITextView 2、UITextField 3、UIWebView 二、UIKit framework提供了几个类和协议方便我们在自己的应用程序中实现剪贴板的功能。 1、UIPasteboard:我们可以向其中写入数据,也可以读取数据 2、UIMenuController:显示一个快捷菜单,用来复制、剪贴、粘贴选择的项。 3、UIResponder中的 canPerformAction:withSender:用于控制哪些命令显示在快捷菜单中。 4、当快捷菜单上的命令点击的时候,UIResponderStandardEditActions将会被调用。 三、下面这些项能被放置到剪贴板中 1、UIPasteboardTypeListString —字符串数组, 包含kUTTypeUTF8PlainText 2、UIPasteboardTypeListURL — URL数组,包含kUTTypeURL 3、UIPasteboardTypeListImage — 图形数组, 包含kUTTypePNG 和kUTTypeJPEG 4、UIPasteboardTypeListColor — 颜色数组 四、剪贴板的类型分为两种: 系统级:使用UIPasteboardNameGeneral和UIPasteboardNameFind创建,系统级的剪贴板,当应用程序关闭,或者卸载时,数据都不会丢失。 应用程序级:通过设置,可以让数据在应用程序关闭之后仍然保存在剪贴板中,但是应用程序卸载之后数据就会失去。我们可用通过pasteboardWithName:create:来创建。 了解这些之后,下面通过一系列的例子来说明如何在应用程序中使用剪贴板。 例子: 1、复制剪贴文本。 下面通过一个例子,可以在tableview上显示一个快捷菜单,上面只有复制按钮,复制tableview上的数据之后,然后粘贴到title上。 定义一个单元格类CopyTableViewCell,在这个类的上显示快捷菜单,实现复制功能。 @interface CopyTableViewCell : UITableViewCell {iddelegate; } @property (nonatomic, retain) iddelegate;@end 实现CopyTableViewCell : #import"CopyTableViewCell.h"@implementation CopyTableViewCell@synthesizedelegate;- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { }return self; }- (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; }- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { [[self delegate] performSelector:@selector(showMenu:) withObject:self afterDelay:0.9f]; [super setHighlighted:highlighted animated:animated]; }- (BOOL)canBecomeFirstResponder {return YES; }- (BOOL)canPerformAction:(SEL)action withSender:(id)sender{if (action == @selector(cut:)){return NO; } elseif(action == @selector(copy:)){return YES; } elseif(action == @selector(paste:)){return NO; } elseif(action == @selector(select:)){return NO; } elseif(action == @selector(selectAll:)){return NO; }else {return [super canPerformAction:action withSender:sender]; } }- (void)copy:(id)sender { UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; [pasteboard setString:[[self textLabel]text]]; }- (void)dealloc { [super dealloc]; }@end 定义CopyPasteTextController,实现粘贴功能。 @interface CopyPasteTextController : UIViewController<UITableViewDelegate> {//用来标识是否显示快捷菜单 BOOL menuVisible; UITableView *tableView; } @property (nonatomic, getter=isMenuVisible) BOOL menuVisible; @property (nonatomic, retain) IBOutlet UITableView *tableView;@end 实现CopyPasteTextController : #import"CopyPasteTextController.h"#import"CopyTableViewCell.h"@implementation CopyPasteTextController@synthesize menuVisible,tableView;- (void)viewDidLoad { [super viewDidLoad]; [self setTitle:@"文字复制粘贴"];//点击这个按钮将剪贴板的内容粘贴到title上 UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(readFromPasteboard:)] autorelease]; [[self navigationItem] setRightBarButtonItem:addButton]; }// Customize the number of sections in the table view.- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {return1; }- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return9; }// Customize the appearance of table view cells.- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {static NSString *CellIdentifier =@"Cell"; CopyTableViewCell *cell = (CopyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];if (cell == nil) { cell = [[[CopyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; [cell setDelegate:self]; }// Configure the cell. NSString *text = [NSString stringWithFormat:@"Row %d", [indexPath row]]; [[cell textLabel] setText:text];return cell; }- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {if([self isMenuVisible]) {return; } [[[self tableView] cellForRowAtIndexPath:indexPath] setSelected:YES animated:YES]; }//显示菜单- (void)showMenu:(id)cell {if ([cell isHighlighted]) { [cell becomeFirstResponder]; UIMenuController * menu = [UIMenuController sharedMenuController]; [menu setTargetRect: [cell frame] inView: [self view]]; [menu setMenuVisible: YES animated: YES]; } }- (void)readFromPasteboard:(id)sender { [self setTitle:[NSString stringWithFormat:@"Pasteboard = %@", [[UIPasteboard generalPasteboard] string]]]; }- (void)didReceiveMemoryWarning {// Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning];// Relinquish ownership any cached data, images, etc that aren't in use.}- (void)viewDidUnload { [super viewDidUnload]; [self.tableView release];// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.// For example: self.myOutlet = nil;} 效果: 复制一行数据: 点击右上角的按钮粘贴,将数据显示在title上: 2、图片复制粘贴 下面通过一个例子,将图片复制和剪贴到另外一个UIImageView中间。 1、在界面上放置两个uiimageview,一个是图片的数据源,一个是将图片粘贴到的地方。CopyPasteImageViewController 代码如下: @interface CopyPasteImageViewController : UIViewController { UIImageView *imageView; UIImageView *pasteView; UIImageView *selectedView; } @property (nonatomic, retain) IBOutlet UIImageView *imageView; @property (nonatomic, retain) IBOutlet UIImageView *pasteView; @property (nonatomic, retain) UIImageView *selectedView;- (void)placeImageOnPasteboard:(id)view;@end 2、当触摸图片的时候我们显示快捷菜单: - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { NSSet *copyTouches = [event touchesForView:imageView]; NSSet *pasteTouches = [event touchesForView:pasteView]; [self becomeFirstResponder];if ([copyTouches count] >0) { [self performSelector:@selector(showMenu:) withObject:imageView afterDelay:0.9f]; }elseif([pasteTouches count] >0) { [self performSelector:@selector(showMenu:) withObject:pasteView afterDelay:0.9f]; } [super touchesBegan:touches withEvent:event]; }- (void)showMenu:(id)view { [self setSelectedView:view]; UIMenuController * menu = [UIMenuController sharedMenuController]; [menu setTargetRect: CGRectMake(5, 10, 1, 1) inView: view]; [menu setMenuVisible: YES animated: YES]; } 这里的快捷菜单,显示三个菜单项:剪贴、粘贴、复制: - (BOOL)canPerformAction:(SEL)action withSender:(id)sender{if (action == @selector(cut:)) {return ([self selectedView] == imageView) ? YES : NO; } elseif (action == @selector(copy:)) {return ([self selectedView] == imageView) ? YES : NO; } elseif (action == @selector(paste:)) {return ([self selectedView] == pasteView) ? YES : NO; } elseif (action == @selector(select:)) {return NO; } elseif (action == @selector(selectAll:)) {return NO; } else {return [super canPerformAction:action withSender:sender]; } }- (void)cut:(id)sender { [self copy:sender]; [imageView setHidden:YES]; }- (void)copy:(id)sender { [self placeImageOnPasteboard:[self imageView]]; }- (void)paste:(id)sender { UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyPasteImage" create:YES]; NSData *data =[appPasteBoard dataForPasteboardType:@"com.marizack.CopyPasteImage.imageView"]; pasteView.image = [UIImage imageWithData:data]; } 效果: 1、点击图片,显示菜单按钮。 2、点击复制,将数据复制到剪贴板上: 3、点击粘贴,将数据粘贴到uiimageview上。 总结:本文详解了iOS系统应用程序中如何使用剪贴板。 本文转自麒麟博客园博客,原文链接:http://www.cnblogs.com/zhuqil/archive/2011/08/04/2127883.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

40条ASP.NET开发Tip

欢迎拍砖,共同进步!!! 1、在compilation 下,请设置debug=false ,如下: defaultLanguage="c#"debug="false"> 2、请使用Server.Transfer代替Response.Redirect。 3、使用Validator控件,请要经常检查Page.IsValid。 4、请使用foreach循环,而不是为字符串迭代循环。 5、请使用客户端验证方式(不要每次都在服务端验证)。 6、为了避免重复代码执行,请检查“Page.IsPostBack”。 7、GIF 和PNG类似,但是PNG通常产生一个较小体积的文件。(当然,有些浏览器不支持PNG格式) 8、更新二进制文件时,请使用AppOffline.htm 。 9、除非需要,否则请关闭跟踪。 < trace enabled ="false" requestLimit ="10" pageOutput ="false" traceMode ="SortByTime" localOnly ="true" /> 10、编译页面,请禁用AutoEventWireup。在Machine.config文件中请设置AutoEventWireup为false。 11、如果不需要,请关闭Session会话。 < sessionstate timeout ="20" cookieless ="false" mode ="Off" stateconnectionstring ="tcpip=127.0.0.1:42424" sqlconnectionstring ="datasource=127.0.0.1;Trusted_Connection=no" > 12、在你生成最终版本的应用程序之前,请选择Release模式。默认是Debug。 13、如果不需要请禁用ViewState 。 EnableViewState="false" 14、请避免频繁的访问数据库。 15、使用缓存提高你的应用程序的性能。 16、验证所有的用户输入。 17、请最后释放所有资源。 18、String 和Stringbuilder。 修改字符串时,使用Stringbuilder而不是String ,在每次字符串修改的时候,String都会占据不同的内存空间,而Stringbuilder只使用同一个内存空间 19、切勿直接使用对象的值,先从本地变量获取对象的值,然后再使用。因为直接读取对象的值比读取变量更花时间。 20、避免异常:使用if。 21、代码优化:避免使用:x = x +1,而是使用x+=1比较好。 22、数据访问技术:DataReaders提供快速有效的数据检索方法。在性能方面,DataReader是速度远远超过DataSets 。 23、在做一个笨重的ASP代码的处理之前,你进行检查以确保Response.IsClientConnected。 24、避免session变量,因为每个ASP页面是在不同的线程运行和session调用将会被逐一序列化。这样会降低应用程序。你可以使用QueryString集合或者表单上面的hidden变量来保存值。 25、使buffer有效,能提高性能,如: <% response.buffer = true %> 接着使用: <% response.flush = true %> 26、使用Repeater控件代替DataGrid,DataList,因为它是高效的,可定制的,和可编程的。 27、在数据库中检索大量数据,数据列表消耗更多的时间。 分页将显示特定的数据,但是要考虑所有数据负载。只取当前页需要的数据。 28、避免内嵌JavaScript和CSS。 29、使用单个的css文件,而不是多个css文件。 请尽量将您所有的css合并成一个css的类文件,不管文件大小,大量的.css文件会造成大量的请求。.css文件通常是由浏览器缓存,这样一个单一的沉重的.css文件不会导致在每个页面请求时会有漫长的等待。 内嵌.CSS类导致HTML沉重,因此我觉得:首先考虑一个single.css文件。 30、减少cookie的大小。 31、压缩CSS, JavaScript 和Images。 可以使用在线的压缩,压缩文件,将下列网页和优化的代码替换为您的文件内容。 http://iceyboard.no-ip.org/projects/css_compressor[^] CSS 压缩www.xtreeme.com/javascript-optimizer/[^] . JS 压缩 32、适当地使用缓存。 i、页面输出缓存: <% @OutputCacheDuration = " 3600 " VaryByParam = " none " %> ii、页片段缓存: 在每个用户控件中写页面输出缓存 iii、数据缓存: 33、服务器端使用诸如Port80s压缩软件http://www.port80software.com/products/httpzip/[^]。 34、使用了“using”。 35、不要声明成员变量为public 或者proteted,尽量使用private 成员变量和public/protected 属性。 36、使用strString=string.Empty代替 strString="" 。 37、请尽可能减轻你的页面文件,尽量避免不必要的标签,例如使用div代替table。 38、在div中写静态的消息,必要的时候才显示出来。这比你设置服务端的label和div的text属性快。 39、如果可能的话,一次性检索数据库中的数据。尽可能不要添加数据库的访问。因此,整合来自不同表datafields和选择它们。 40、给WebControl取个简短的名字。 本文转自麒麟博客园博客,原文链接:http://www.cnblogs.com/zhuqil/archive/2010/01/16/40-ASP_NET-Tip.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android开发中的Intent和Activity

周末撸了几次代码, 舍不得扔, 立此为照! mainActivity.java package com.tw.flag.ch08_memo; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener { String[] aMemo = { "1.单击可以编辑备忘", "2.长按可以清除备忘", "3.", "4.", "5.", "6" }; ListView lv; ArrayAdapter<String> aa; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); lv = (ListView)findViewById(R.id.listView); aa = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, aMemo); lv.setAdapter(aa); lv.setOnItemClickListener(this); lv.setOnItemLongClickListener(this); } @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent it = new Intent(this, Edit.class); it.putExtra("备忘", aMemo[position]); startActivityForResult(it, position); } protected void onActivityResult(int requestCode, int resultCode, Intent it) { if (resultCode == RESULT_OK) { aMemo[requestCode] = it.getStringExtra("备忘"); aa.notifyDataSetChanged(); } } @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { aMemo[position] = (position+1) + "."; aa.notifyDataSetChanged(); return true; } } Edit.java package com.tw.flag.ch08_memo; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; public class Edit extends AppCompatActivity { TextView txv; EditText edt; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit); Intent it = getIntent(); String s = it.getStringExtra("备忘"); txv = (TextView)findViewById(R.id.textView); txv.setText(s.substring(0, 2)); edt = (EditText)findViewById(R.id.editText); if (s.length() > 3) edt.setText(s.substring(3)); } public void onCancel(View v) { setResult(RESULT_CANCELED); finish(); } public void onSave(View v) { Intent it2 = new Intent(); it2.putExtra("备忘", txv.getText() + " " + edt.getText()); setResult(RESULT_OK, it2); finish(); } } 你的样子:

资源下载

更多资源
Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册