Fork me on GitHub

2012年2月28日

摘要: 一般是在你需要添加自定义navigationbar的地方:self.navigationController.navigationBar.hidden = YES;UINavigationBar *customNavigationBar = [[[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)] autorelease];UIImageView *navigationBarBackgroundImageView = [[UIImageView alloc] initWithImage:backgroundImage] 阅读全文
posted @ 2012-02-28 19:44 pengyingh 阅读(7286) 评论(0) 推荐(0)
摘要: 我们在C/C++开发中常会用到结构体来帮助我们简单封装基本数据类型,在Objective-C中我们也可以使用结构体来完成数据类型的封装。同时,Cocoa Touch还提供了一个NSValue来帮助我们更好地在开发中使用结构体。 我们可以使用NSValue来辅助我们实现一些简单数据结构的封装。比如我们定义了一个简单的结构体类型typedef struct { int id, float height, unsigned char flag}MyTestStruct; 此时,我们就可以使用MyTestStruct这个结构体来很容易地封装数据。如 MyTestStruct myTestStruct; 阅读全文
posted @ 2012-02-28 13:44 pengyingh 阅读(10107) 评论(0) 推荐(2)
摘要: 实例:2:使用NSOperation和NSOperationQueue启动多线程在app store中的很多应用程序非常的笨重,他们有好的界面,但操作性很差,比如说当程序从网上或本地载入数据的时候,界面被冻结了,用户只能等程序完全载入数据之后才能进行操作。当打开一个应用程序时,iphone会产生一个包含main方法的线程,所用程序中的界面都是运行在这个线程之中的(table views, tab bars, alerts…),有时候我们会用数据填充这些view,现在问 题是如何有效的载入数据,并且用户还能自如的操作程序。方法是启动新的线程,专门用于数据的下载,而主线程不会因为下载... 阅读全文
posted @ 2012-02-28 13:36 pengyingh 阅读(2378) 评论(0) 推荐(0)
摘要: NSData和结构体struct之间如何转换用处是当用NSNotification传递数据时需要这个转换,然后把NSData放到userInfo中。// make a NSData objectNSData *myData = [NSData dataWithBytes:&myPacketJoin length:sizeof(myPacketJoin)];// make a new PacketJoinPacketJoin newJoin;[myData getBytes:&newJoin length:sizeof(newJoin)];struct msg {uint32_t 阅读全文
posted @ 2012-02-28 13:21 pengyingh 阅读(2615) 评论(0) 推荐(0)
摘要: Search and Comparison OptionsThese values represent the options available to many of the string classes’ search and comparison methods.enum { NSCaseInsensitiveSearch = 1, NSLiteralSearch = 2, NSBackwardsSearch = 4, NSAnchoredSearch = 8, NSNumericSearch = 64, NSDiacriticInsensitiveSearch = 128, NSWid 阅读全文
posted @ 2012-02-28 12:57 pengyingh 阅读(915) 评论(0) 推荐(0)
摘要: NSDictionary和NSArray、NSString都是容器NSString *str=[[NSString alloc]initWithString:@"123"];含义:分配内存k,存储字符串"123",指针str指向这个内存地址;NSString *strTemp=str;含义:将指针str指向的地址传递给指针strTemp两个指针str、strTemp指向同一个地址KNSArray *arr=[[NSArray alloc]initWithObject:strTemp];[arr objectAtIndex:0]也是指针,也指向地址K情况1 阅读全文
posted @ 2012-02-28 12:49 pengyingh 阅读(118) 评论(0) 推荐(0)
摘要: libxml的attributes参数用结构体表示static void startElementSAX (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_de... 阅读全文
posted @ 2012-02-28 11:25 pengyingh 阅读(439) 评论(0) 推荐(0)

导航