摘要: 在输入东西的时候,如果想限制最大字数,可以用下面方法- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;{if ([string isEqualToString:@"\n"]){return YES;}NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withStrin 阅读全文
posted @ 2012-08-18 12:37 careerman 阅读(3777) 评论(0) 推荐(0) 编辑
摘要: 实现以下三个方法,如果弹出的键盘会遮住输入框 ,整体的界面会向上移动,这样就不会遮住输入框了。自己增加UITextFieldDelegate委托。只适合iPhone,如果想要支持iPad,只要把216改成iPad上面键盘的高度即可。- (void)keyboardWillShow:(NSNotification *)noti{//键盘输入的界面调整//键盘的高度float height = 216.0;CGRect frame = self.view.frame;frame.size = CGSizeMake(frame.size.width, frame.size.height - heig 阅读全文
posted @ 2012-08-18 12:34 careerman 阅读(164) 评论(0) 推荐(0) 编辑
摘要: iphone 定时器的使用iphone 模拟器可以起2个以上的定时器。但是真机测试还没做!-(void)timerButtonClicked:(id) sender {NSLog(@"timerButtonClicked is used!");static BOOLflag =YES;staticNSTimer*myTimer;if(flag ==YES) {//起定时器myTimer = [NSTimerscheduledTimerWithTimeInterval:1target:selfselector:@selector(onTimer:)//回调函数userInfo 阅读全文
posted @ 2012-08-18 12:11 careerman 阅读(197) 评论(0) 推荐(0) 编辑
摘要: #include<unistd.h>#include<netdb.h>#include<arpa/inet.h>#include<string.h>charbaseHostName[255];gethostname(baseHostName,255);//获得本机名字structhostent *host =gethostbyname(baseHostName);//将本机名字转换成主机网络结构体struct hostentif(host ==NULL) {herror("resolv");}else{structin_add 阅读全文
posted @ 2012-08-18 12:04 careerman 阅读(322) 评论(0) 推荐(0) 编辑
摘要: myImage = [UIImage imageNamed:@"icon.png"];那么小心了这种方法在一些图片很少,或者图片很小的程序里是ok的。但是,在大量加载图片的程序里,请千万不要这样做。为什么呢 ???????这种方法在application bundle的顶层文件夹寻找由供应的名字的图象 。 如果找到图片,装载到iPhone系统缓存图象。那意味图片是(理论上)放在内存里作为cache的。试想你图片多了,是什么后果``````图片cache极有可能不会响应 memory warnings and release its objects所以,用图片的时候一定要小心 阅读全文
posted @ 2012-08-17 23:06 careerman 阅读(260) 评论(0) 推荐(0) 编辑
摘要: NSBundle的对象可以获取应用程序安装目录的附件。附件包括了,当前应用程序下,所有的文件。(图片、属性列表等)获取XML文件NSString*filePath=[[NSBundlemainBundle]pathForResouse:@"re"ofType:@"xml"]; NSData*data=[[NSDataalloc]initWithContentsOfFile:filePath];获取属性列表NSDictionary*dict=[NSDictionarydictionaryWithContentsOfFile:[[NSBundlemainBu 阅读全文
posted @ 2012-08-17 23:04 careerman 阅读(140) 评论(0) 推荐(0) 编辑
摘要: IPHONEhttp://developer.apple.com/library/ios/navigation/#section=Resource%20Types&topic=Sample%20CodeMAChttp://developer.apple.com/library/mac/navigation/index.html#topic=Sample+Code&section=Resource+Type 阅读全文
posted @ 2012-08-16 21:18 careerman 阅读(1889) 评论(0) 推荐(0) 编辑
摘要: 转自:http://blog.sina.com.cn/s/blog_7a2ffd5c0100uquw.html一直使用@property,今天特意整理了一下相关的资料。主要原因还是在对一个CCSprite*类型的数据成员进行赋值,在使用中一直报空指针crash掉。仔细回想了一下内存处理机制,我们在Object-C中,只要不是自己alloc创建的对象,都是autorelease,都不要我们管理。比如一开始我一直使用[NSMutableArray arrayWithCapacity:]创建,但创建后的mutableArray是AutoRelease型,所以在使用中会报空指针。其实我们可以手动创建如 阅读全文
posted @ 2012-08-16 15:45 careerman 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 在这个坛子注册了一年多,现在才开始想要写点什么,之前都是在ccidnet上面进行记录,而且那边访问量也已经突破100万,但那边的网站不稳定,时常更新升级,索性从新开始,打算在这个博客网站一点一点开始新的旅程。 阅读全文
posted @ 2012-07-18 14:45 careerman 阅读(157) 评论(0) 推荐(0) 编辑