Fork me on GitHub
上一页 1 ··· 99 100 101 102 103 104 105 106 107 ··· 125 下一页

2012年2月12日

摘要: Category和Extension这两个概念,即便对于Java程序员,可能也会感到陌生。这是Objective C为程序员提供的两个强大的动态机制——简单地说,它们允许程序员为已有的对象添加新的方法,即便是在没有该对象的源代码的情况下。Category准确的定义是这样的:Category拥有一个名字,它不需要使用子类(Subclassing)机制,就允许向一个类文件中添加新的方法声明,并且在类实现的文件中的同一个名字下定义这些方法。其语法举例如下:#import "ClassName.h"@interface ClassName ( CategoryName )// me 阅读全文
posted @ 2012-02-12 23:17 pengyingh 阅读(3514) 评论(0) 推荐(2)
摘要: 原文:http://lovebirdegg.co.tv/2010/03/filtering-fun-with-predicates-filtering-fun-with-predicates/Being present longer than iPhone OS exists on the Mac platform NSPredicate was only introduced to us iPhone developers in Version 3.0 of the SDK. They have multiple interesting uses, some of which I am go 阅读全文
posted @ 2012-02-12 19:37 pengyingh 阅读(528) 评论(0) 推荐(0)
摘要: //找出一个数组NSFileManager*fileManager=[NSFileManagerdefaultManager];NSString*defaultPath=[[NSBundlemainBundle]resourcePath];NSError*error;NSArray*directoryContents=[fileManagercontentsOfDirectoryAtPath:defaultPatherror:&error]//匹配字符串,反回结果,SELF==表示数组中每一个元素NSString*match=@"imagexyz-999.png"; 阅读全文
posted @ 2012-02-12 18:28 pengyingh 阅读(455) 评论(0) 推荐(0)
摘要: iphone里面角度和弧度经常要转换比如旋转一个图片,你要用到CGAffineTransformMakeRotation,他就需要一个弧度值做完输入。下面是两个宏,来实现互转1。弧度转角度#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))NSLog(@"Output radians as degrees: %f", RADIANS_TO_DEGREES(0.785398));2。角度转弧度// Degrees to radians#define DEGREES_TO_RADIANS(angle) 阅读全文
posted @ 2012-02-12 11:10 pengyingh 阅读(981) 评论(0) 推荐(0)
摘要: // Disable the idle timer[[UIApplication sharedApplication]setIdleTimerDisabled:YES]; // Or for those who prefer dot syntax:[UIApplication sharedApplication].idleTimerDisabled=YES; 阅读全文
posted @ 2012-02-12 11:10 pengyingh 阅读(167) 评论(0) 推荐(0)
摘要: - (NSMutableArray *)loadMarkersFromFilePath:(NSString *)filePath { NSMutableArray *markers = nil; if (filePath == nil || [filePath length] == 0 || [[NSFileManager defaultManager] fileExistsAtPath:filePath] == NO) { markers = [[[NSMutableArray alloc] init] autorelease]; } else { NSData *data = [[N... 阅读全文
posted @ 2012-02-12 11:07 pengyingh 阅读(8349) 评论(0) 推荐(0)
摘要: # Objective-C做的一个Framework跟App整合到一起,因为用到了多线程,所以通信不可避免,但是Framework里又载入了一个C++的Plugin,里面有许多struct,在把这类struct变成对象序列化时遇到问题。以前做的很傻,把struct的所有成员用NSDictionary来一个个封装,再一个个反序列化,好傻呀。要是struct定义变了,那代码就又要修改了~所以重构了一下,这里给出怎样对non object数据结构进行对象封装和序列化。怎样进行封装是引用JongAm‘s一篇博文。原文地址:http://jongampark.wordpress.com/2008/08/ 阅读全文
posted @ 2012-02-12 10:41 pengyingh 阅读(424) 评论(0) 推荐(0)
摘要: #import<UIKit/UIKit.h>@interfaceDropDownList : UIView<UITableViewDelegate,UITableViewDataSource> {UITextField* textField; //文本输入框NSArray* list; //下拉列表数据BOOLshowList; //是否弹出下拉列表UITableView* listView; //下拉列表CGRect oldFrame,newFrame; //整个控件(包括下拉前和下拉后)的矩形UIColor *lineColor,*listBgColor;//下拉框 阅读全文
posted @ 2012-02-12 08:42 pengyingh 阅读(312) 评论(0) 推荐(0)
摘要: 有时我们需要动态调整UITableViewCell的高度,根据内容的不同设置不同的高度,以前看到一种实现方法,写得有点麻烦,具体地址找不到了,这里有个更好的(至少我认为),分享一下部分代码。- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusa 阅读全文
posted @ 2012-02-12 07:59 pengyingh 阅读(12940) 评论(0) 推荐(0)
摘要: iphone中 CoreData 框架的简单解释 并非严格的说, CoreData是对sqlite数据库的一个封装. sqlite数据库操作的基本流程是, 创建数据库, 再通过定义一些字段来定义表格结构, 可以利用sql语句向表格中插入记录, 删除记录, 修改记录, 表格之间也可以建立联系. 这个过程出现了, 表格的结构(schema), 所有表格的结构和相互联系构成整个数据库的模型,数据库存放的方式(可以是文件或者在内存),数据库操作, sql语句(主要是查询), 表格里面的记录 下面将上面说的文字, 跟CoreData的类作个对应: 表格结构 --> NSEntityDescri.. 阅读全文
posted @ 2012-02-12 07:28 pengyingh 阅读(203) 评论(0) 推荐(0)
上一页 1 ··· 99 100 101 102 103 104 105 106 107 ··· 125 下一页

导航