上一页 1 2 3 4 5 6 ··· 9 下一页
摘要: 可以在AppDelegate内写,也可以自己定义单例来写这个操作。 1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 2 { 3 // Override point for customization after application launch. 4 5 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selec... 阅读全文
posted @ 2013-11-18 11:21 ubersexual 阅读(349) 评论(0) 推荐(0) 编辑
摘要: Quartz2D提供了两种渐变填充方法。第一种是使用Quartz自带的Gradient填充方法;第二种是使用自定义的着色器。这里将先描述如何使用CGGradient对象来做渐变填充。 1 // Drawing code 2 3 // 创建Quartz上下文 4 CGContextRef context = UIGraphicsGetCurrentContext(); 5 6 // 创建色彩空间对象 7 CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); 8 9... 阅读全文
posted @ 2013-11-16 00:02 ubersexual 阅读(298) 评论(0) 推荐(0) 编辑
摘要: 使用之前请从Apple网站下载示例:点此下载然后将Reachability.h 和Reachability.m 加到自己的项目中,并引用SystemConfiguration.framework,就可以使用了。Reachability 中定义了3种网络状态 1 // the network state of the device for Reachability 1.5. 2 typedef enum { 3 NotReachable = 0, //无连接 4 ReachableViaCarrierDataNetwork, //使用3G/GPRS网络 5 Reacha... 阅读全文
posted @ 2013-11-14 09:08 ubersexual 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 当你创建一个project时,会要求你输入product name & company identifier,这两个property的值should和你在apple developer member center的“Provisioning Portal”的“App IDs"里创建的bundle identifier (NOT App ID)匹配!如果不匹配的话,push notification feature和cloud feature则不成功!!例如,当你创建的App ID时,设置的"Bundle Seed ID (App ID Prefix)"为& 阅读全文
posted @ 2013-11-13 10:14 ubersexual 阅读(5667) 评论(0) 推荐(0) 编辑
摘要: 使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形步骤:1、新建UIBezierPath对象bezierPath2、新建CAShapeLayer对象caShapeLayer3、将bezierPath的CGPath赋值给caShapeLayer的path,即caShapeLayer.path =bezierPath.CGPath4、把caShapeLayer添加到某个显示该图形的layer中下面的小例子是一个环形的progress代码,有具体的使用方法.h文件: 1 #import 2 3 @interface KACirc.. 阅读全文
posted @ 2013-11-08 12:21 ubersexual 阅读(870) 评论(0) 推荐(0) 编辑
摘要: 碰到这样的错误:JSONValue failed. Error is: Unescaped control character [0x09]有如下解决方案: 1 -(NSString *)removeUnescapedCharacter:(NSString *)inputStr 2 { 3 4 NSCharacterSet *controlChars = [NSCharacterSet controlCharacterSet]; 5 6 NSRange range = [inputStr rangeOfCharacterFromSet:controlChars]; 7 8 if (r... 阅读全文
posted @ 2013-11-07 13:48 ubersexual 阅读(375) 评论(0) 推荐(0) 编辑
摘要: 1 NSString *postURL = [NSString stringWithFormat:@"http://xxxxxx.php?mod=%@&data=%@", mod, data];2 3 NSLog(@"发送注册请求URL:%@", postURL);4 5 ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:postURL]];6 7 [request startSynchronous];如果是 Get ,或者参数可以 阅读全文
posted @ 2013-11-07 12:33 ubersexual 阅读(567) 评论(0) 推荐(0) 编辑
摘要: 1 //对图片尺寸进行压缩-- 2 -(UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize 3 { 4 // Create a graphics image context 5 UIGraphicsBeginImageContext(newSize); 6 7 // Tell the old image to draw in this new context, with the desired 8 // new size 9 [image drawInRec... 阅读全文
posted @ 2013-11-06 17:23 ubersexual 阅读(335) 评论(0) 推荐(0) 编辑
摘要: 无论是爱还是恨,你都需要单例。实际上每个iOS或Mac OS应用都至少会有UIApplication或NSApplication.什么是单例呢?Wikipedia是如此定义的:在软件工程中,单例是一种用于实现单例的数学概念,即将类的实例化限制成仅一个对象的设计模式。或者我的理解是:单例是一种类,该类只能实例化一个对象。 尽管这是单例的实际定义,但在Foundation框架中不一定是这样。比如NSFileManger和NSNotificationCenter,分别通过它们的类方法defaultManager和defaultCenter获取。尽管不是严格意义的单例,这些类方法返回一个可以在应用的所 阅读全文
posted @ 2013-11-05 17:01 ubersexual 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 最近在做一个UITableView的例子,发现滚动时的性能还不错。但来回滚动时,第一次显示的图像不如再次显示的图像流畅,出现前会有稍许的停顿感。于是我猜想显示过的图像肯定是被缓存起来了,查了下文档后发现果然如此。后来在《Improving Image Drawing Performance on iOS》一文中找到了一些提示:原来在显示图像时,解压和重采样会消耗很多CPU时间;而如果预先在一个bitmap context里画出图像,再缓存这个图像,就能省去这些繁重的工作了。接着我就写了个例子程序来验证: 1 // ImageView.h 2 3 #import 4 5 6 @inte... 阅读全文
posted @ 2013-10-16 16:00 ubersexual 阅读(371) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 9 下一页