摘要:
在输入东西的时候,如果想限制最大字数,可以用下面方法- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;{if ([string isEqualToString:@"\n"]){return YES;}NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withStrin 阅读全文
摘要:
实现以下三个方法,如果弹出的键盘会遮住输入框 ,整体的界面会向上移动,这样就不会遮住输入框了。自己增加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 阅读全文
摘要:
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 阅读全文
摘要:
#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 阅读全文