Fork me on GitHub
上一页 1 ··· 74 75 76 77 78 79 80 81 82 ··· 125 下一页

2012年3月4日

摘要: Sqlite是一个用C语言实现的小型SQL数据库引擎。它体积小巧但功能强大,对硬件资源要求很低而且性能表现卓越,非常适合于嵌入式应用环境。最近发现sqlite并不支持中文(拼音/笔画)排序,而这个功能又是我们必需的,所以花了些时间去研究。 我们知道,计算机中的每一个字符都有一个内码。在默认情况下,计算机排序时,比较两个字符的大小就是比较字符内码的大小,这对于英文来说没有问题,因为英文字母的内码是按字母顺序递增的。对于中文来说,就比较麻烦了:首先,中文的排序方式有多种,比如按内码排序、按拼音排序和按笔画排序,要通过参数指定排序的方式,否则计算机就按内码排序了。其次,汉字的内码顺序即不同于拼音.. 阅读全文
posted @ 2012-03-04 21:10 pengyingh 阅读(1836) 评论(0) 推荐(0)
摘要: 用UIImage加载图像的方法很多,最常用的是下面两种: 1、用imageNamed函数 [UIImage imageNamed:ImageName]; 2、用NSData的方式加载,例如: 1. NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:extension]; 2. NSData *image = [NSData dataWithContentsOfFile:filePath]; 3. [UIImage imageWithData:image]; 由于第一种方式要写的代... 阅读全文
posted @ 2012-03-04 20:53 pengyingh 阅读(215) 评论(0) 推荐(0)
摘要: iPhone内存管理中,涉及到malloc在堆上分配内存时,需要使用对应的free释放堆内存,而不是单纯的release相关的对象了事,如下代码: @interface MemoryTestProjViewController : UIViewController { @public NSMutableArray * memoryArray; } @end @interface MemoryTestProjItem : NSObject { @public char * innerItem; } @end 在进行初始化时为innerItem指针在堆空间上分配内存,但是要... 阅读全文
posted @ 2012-03-04 20:49 pengyingh 阅读(227) 评论(0) 推荐(0)
摘要: 我们可以使用以下方法进行编码转换 NSString* str2 = [NSString stringWithCString:str1 encoding:enc1]; 再调用NSString的cStringUsingEncoding:enc2实现从enc1到enc2的转换 但是获取enc枚举值是个难题 1. NSString.h中只定义了以下编码值 enum { NSASCIIStringEncoding = 1, /* 0..127 only */ NSNEXTSTEPStringEncoding = 2, NSJapaneseEUCStringEncoding = 3, N... 阅读全文
posted @ 2012-03-04 20:42 pengyingh 阅读(510) 评论(0) 推荐(0)
摘要: UIWebView加载Loading...两种方法 第一种方法:使用UIView and UIActivityIndicatorView //创建UIWebView WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 44, 320, 400)]; [WebView setUserInteractionEnabled:NO]; [WebView setBackgroundColor:[UIColor clearColor]]; [WebView setDelegate:self]; [WebView setOpaque... 阅读全文
posted @ 2012-03-04 20:37 pengyingh 阅读(211) 评论(0) 推荐(0)
摘要: 一、如果想把模拟其中保存的数据在真机中显示出来,可以在 AppDelegate 里用下面方法: 模拟器保存完数据,然后进入目录:“用户名/Library/Application Support/iPhone Simulator/4.2/Applications/" 目录下,找到 p.sqlite,复制到软件的工程目录里。然后导入到工程里面,这样可以用模拟器里面保存的数据了。 - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel != nil) { return managedObjectModel; 阅读全文
posted @ 2012-03-04 19:29 pengyingh 阅读(1154) 评论(0) 推荐(0)
摘要: 在iOS开发中,如果提前释放一个指针的内存,在以后还继续使用这个指针,那么程序会立刻 crash 掉,而且很难有报错信息,我们应该利用工具去找到错误的地方,然后快速准确的定位到错误地方,及其错误原因,最后进行改进。 其实iOS控制台提供这种机制,如果你选择 debug 模式,在程序 crash 之后,在控制台输入 bt,就可以显示 crash 堆栈: Program received signal: “EXC_BAD_ACCESS”. warning: Unable to read symbols for /Developer/ios4.2.1/Platforms/iPhoneOS.pl... 阅读全文
posted @ 2012-03-04 19:23 pengyingh 阅读(418) 评论(0) 推荐(0)
摘要: 创建.plist文件并存储 NSString *errorDesc; //用来存放错误信息 NSMutableDictionary *rootObj = [NSMutableDictionary dictionaryWithCapacity:4]; //NSDictionary, NSData等文件可以直接转化为plist文件 NSDictionary *innerDict; NSString *name; Player *player; NSInteger saveIndex; for(int i = 0; i < [playerArray count]; i++) { pl... 阅读全文
posted @ 2012-03-04 19:19 pengyingh 阅读(367) 评论(0) 推荐(0)
摘要: 首先要在工程里加入Audio Toolbox framework这个库,然后在需要调用的文件里#import 最后在需要播放提示音的地方写上 AudioServicesPlaySystemSound(1106); 注:括号中为系统声音的id,详见最下面的列表。 为了方便大家测试系统声音,我写了一个demo供大家使用下载。 另外,如果想用自己的音频文件创建系统声音来播放的同学可以参考如下代码。 //Get the filename of the sound file: NSString *path = [NSString stringWithFormat:@"%@%@", [ 阅读全文
posted @ 2012-03-04 19:04 pengyingh 阅读(260) 评论(0) 推荐(0)
摘要: 在3.2以前,我们要拿到UITouch跟使用者互动,大部分都是透过UIResponder的四种methods - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesMoved:(NSSet *)touches with... 阅读全文
posted @ 2012-03-04 19:00 pengyingh 阅读(1564) 评论(0) 推荐(0)
上一页 1 ··· 74 75 76 77 78 79 80 81 82 ··· 125 下一页

导航