摘要: 创建单例的步骤:声明一个单例对象的静态实例,并初始化为nil。在该类的类工厂方法(名称类似于“sharedInstance”或“sharedManager”)中生成该类的一个实例,但仅当静态实例为nil的时候。重载allocWithZone:方法,确保当用户试图直接(而不是通过类工厂方法)分配或初始化类的实例时,不会分配出另一个对象。实现基本协议方法:copyWithZone:、release、retain、retainCount、和autorelease,以保证单例的状态。实现单例的代码例子:(iOS设计模式 page83)#import "Singleton.h"@im 阅读全文
posted @ 2012-10-25 13:42 hellocby 阅读(1449) 评论(0) 推荐(0) 编辑
摘要: #import <QuartzCore/QuartzCore.h> //给图层添加背景图片: myView.layer.contents = (id)[UIImage imageNamed:@"view_BG.png"].CGImage; //将图层的边框设置为圆脚 myWebView.layer.cornerRadius = 8; myWebView.layer.masksToBounds = YES; //给图层添加一个有色边框myWebView.layer.borderWidth = 5;myWebView.layer.borderColor = [[UI 阅读全文
posted @ 2012-10-25 11:18 hellocby 阅读(417) 评论(0) 推荐(0) 编辑
摘要: contentSize是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,-480),也就是y偏移了- 480(注意向下拉,偏移是负数,向上才是正数,这个我测试过的)contentInset是scrollview的contentview的顶点相对于scrollview的位置,例 阅读全文
posted @ 2012-10-11 14:26 hellocby 阅读(142) 评论(0) 推荐(0) 编辑
摘要: iPhone开发之深入浅出 (1) — ARC是什么博主:易飞扬原文链接:http://www.yifeiyang.net/development-of-the-iphone-simply-1/iPhone开发之深入浅出 (2) — ARC之@property使用博主:易飞扬原文链接:http://www.yifeiyang.net/development-of-the-iphone-simply-2/iPhone开发之深入浅出 (3) — ARC之前世今生博主:易飞扬原文链接:http://www.yifeiyang.net/development-of-the-iphone-simply- 阅读全文
posted @ 2012-09-28 16:25 hellocby 阅读(345) 评论(0) 推荐(0) 编辑
摘要: xcode 4.2非常可恶,原来的代码里有调用performselector:withObject:的地方无一例外获得一个警告:Semantic IssuePerformSelector may cause a leak because its selector is unknownwarning倒是不影响程序运行,但是这人要是有点代码小洁癖的话,那日子就没法过了,这warning怎么看都碍眼。所以必须得想办法把它弄没了:#pragma clang diagnostic push#pragma clang diagnostic ignored "-Warc-performSelect 阅读全文
posted @ 2012-09-28 11:40 hellocby 阅读(231) 评论(0) 推荐(0) 编辑
摘要: http://raptureinvenice.com/arc-support-without-branches/ 阅读全文
posted @ 2012-09-28 11:38 hellocby 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 去这里http://developer.apple.com/iphone/library/samplecode/Reachability/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007324-Intro-DontLinkElementID_2下载Reachability.m和Reachability.h,然后添加到你的项目里面,在需要测试网络连接class里面写这样的一个方法- (BOOL)testConnection {BOOL result = YES;Reachability *reach=[Reachability shared 阅读全文
posted @ 2012-09-19 17:34 hellocby 阅读(1159) 评论(0) 推荐(0) 编辑
摘要: 1.导入MessageUI.framework框架2.在需要应用的控制器头文件:#import <MessageUI/MessageUI.h>,并加入委托:<MFMailComposeViewControllerDelegate>3.实现方法:-(void)displayComposerSheet{ MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setSubject:@ 阅读全文
posted @ 2012-09-19 14:49 hellocby 阅读(4465) 评论(0) 推荐(0) 编辑
摘要: -(void)leftClick{[UIViewbeginAnimations:nilcontext:nil];//displaymode,slowatbeginningandend[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];//动画时间[UIViewsetAnimationDuration:1.0f];//使用当前正在运行的状态开始下一段动画[UIViewsetAnimationBeginsFromCurrentState:YES];//给视图添加过渡效果[UIViewsetAnimationTransition:UIVie 阅读全文
posted @ 2012-09-17 16:36 hellocby 阅读(284) 评论(0) 推荐(0) 编辑
摘要: nil: Anullpointer to an Objective-C object.
( #definenil((id)0) )
Nil: Anullpointer to an Objective-C class.
NULL: Anullpointer to anything else. ( #defineNULL((void *)0) )
NSNull: A class defines a singleton object used to representnullvalues in collection objects (which don't allownilvalues).
 阅读全文
posted @ 2012-09-16 21:26 hellocby 阅读(397) 评论(0) 推荐(1) 编辑