摘要: 效果如图:可以根据输入的关键字,在TableView中显示符合的数据。图中分组显示和索引效果,前面的博文已经记录,不再赘述。下面的例子是基于前文的基础上修改的,所以文件名啥的,请参考前文。第一步是在TableView上方添加一个Search Bar,这里有一点需要注意,必须先把TableView拖下来,留下空间放Search Bar,不要在Table View占满屏幕的情况下把Search Bar拖到Table View顶部。区别在于,使用后面的方法,Search Bar是作为Table View的Header部分添加的,而前面的方法,Search Bar是独立的。在添加索引功能时,如果作为T 阅读全文
posted @ 2012-08-18 13:18 careerman 阅读(11526) 评论(1) 推荐(2)
摘要: NSString *pathList = [[NSBundle mainBundle] pathForResource:@"models" ofType:@"json"];NSString *sourceList = [NSString stringWithContentsOfFile:pathList encoding:NSUTF8StringEncoding error:nil];NSDictionary *resultList = [sourceList objectFromJSONString];//以系名的首個字目為分組名,重新生成可變數組NS 阅读全文
posted @ 2012-08-18 12:59 careerman 阅读(369) 评论(0) 推荐(0)
摘要: 在输入东西的时候,如果想限制最大字数,可以用下面方法- (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 阅读(3785) 评论(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 阅读(172) 评论(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 阅读(208) 评论(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 阅读(333) 评论(0) 推荐(0)