学习iphone时的部分小代码.docx_第1页
学习iphone时的部分小代码.docx_第2页
学习iphone时的部分小代码.docx_第3页
学习iphone时的部分小代码.docx_第4页
学习iphone时的部分小代码.docx_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

NSString 常用方法/lovekarri/articles/2380033.html 占位符格式/bl1988530/article/details/6617358textField 详略/UIKit框架支持8种风格键盘。/typedef enum / UIKeyboardTypeDefault, / 默认键盘:支持所有字符 / UIKeyboardTypeASCIICapable, / 支持ASCII的默认键盘 / UIKeyboardTypeNumbersAndPunctuation, / 标准电话键盘,支持+*#等符号 / UIKeyboardTypeURL, / URL键盘,有.com按钮;只支持URL字符 / UIKeyboardTypeNumberPad, /数字键盘 / UIKeyboardTypePhonePad, / 电话键盘 / UIKeyboardTypeNamePhonePad, / 电话键盘,也支持输入人名字 / UIKeyboardTypeEmailAddress, / 用于输入电子邮件地址的键盘 / UIKeyboardType; /用法/ textView.keyboardtype = UIKeyboardTypeNumberPad; /键盘外观/typedef enum / UIKeyboardAppearanceDefault, / 默认外观:浅灰色 / UIKeyboardAppearanceAlert, /深灰/石墨色 / UIKeyboardAppearance; IKeyboardAppearance;/用法/textView.keyboardAppearance=UIKeyboardAppearanceDefault; /回车键/typedef enum / UIReturnKeyDefault, /默认:灰色按钮,标有Return / UIReturnKeyGo, /标有Go的蓝色按钮 / UIReturnKeyGoogle, /标有Google的蓝色按钮,用于搜索 / UIReturnKeyJoin, /标有Join的蓝色按钮 / UIReturnKeyNext, /标有Next的蓝色按钮 / UIReturnKeyRoute, /标有Route的蓝色按钮 / UIReturnKeySearch, /标有Search的蓝色按钮 / UIReturnKeySend, /标有Send的蓝色按钮 / UIReturnKeyYahoo, /标有Yahoo!的蓝色按钮,用于搜索 / UIReturnKeyDone, /标有Done的蓝色按钮 / UIReturnKeyEmergencyCall, /紧急呼叫按钮 / UIReturnKeyType; /用法/textView.returnKeyType=UIReturnKeyGo; /自动大写/typedef enum / UITextAutocapitalizationTypeNone, /不自动大写 / UITextAutocapitalizationTypeWords, /单词首字母大写 / UITextAutocapitalizationTypeSentences, /句子首字母大写 / UITextAutocapitalizationTypeAllCharacters, /所有字母大写 / UITextAutocapitalizationType; /用法/textField.autocapitalizationType = UITextAutocapitalizationTypeWords; /自动更正/typedef enum / UITextAutocorrectionTypeDefault,/默认 / UITextAutocorrectionTypeNo,/不自动更正 / UITextAutocorrectionTypeYes,/自动更正 / UITextAutocorrectionType; /用法/textField.autocorrectionType = UITextAutocorrectionTypeYes; /安全文本输入/textView.secureTextEntry=YES; /UITextField * newTextFiled= UITextField alloc initWithFrame:CGRectMake(50, 50, 200, 30 );/1. 设置键盘的风格/newTextFiled.keyboardType=UIKeyboardTypeDefault; /默认/2. 设置键盘外观/newTextFiled.keyboardAppearance=UIKeyboardAppearanceDefault; /默认浅灰色颜色/3. 回车键/newTextFiled.returnKeyType=UIReturnKeyGo; /回车 /4.自动大写/newTextFiled.autocapitalizationType=UITextAutocapitalizationTypeNone; /默认/5.自动更正/newTextFiled.autocorrectionType=UITextAutocorrectionTypeYes; /自动更正/6.安全文本输入(密码)/newTextFiled.secureTextEntry=NO;/7.设置按钮边框/newTextFiled.borderStyle=UITextBorderStyleRoundedRect;/8.设置textFiled提示信息/newTextFiled.placeholder=hello world;/委托方法(遮挡键盘)/TextFiled:/- (void)textFieldDidBeginEditing:(UITextField *)textField/ /开始编辑时触发,文本字段将成为first responder/委托方法/TextFiled:/- (void)textFieldDidEndEditing:(UITextField *)textField/ /开始编辑时触发,文本字段将成为first responder/-(void)textFieldDidBeginEditing:(UITextField *)textField UIView beginAnimations:nil context:NULL; UIView setAnimationDuration:0.3; UIView setAnimationDelegate:self; /设定动画开始时的状态为目前画面上的样子 UIView setAnimationBeginsFromCurrentState:YES; if(textField.frame.origin.y210) textField.frame = CGRectMake(textField.frame.origin.x, textField.frame.origin.y - 210, textField.frame.size.width, textField.frame.size.height); UIView commitAnimations; /当textField编辑结束时调用的方法-(void)textFieldDidEndEditing:(UITextField *)textField UIView beginAnimations:nil context:NULL; UIView setAnimationDuration:0.3; UIView setAnimationDelegate:self; /设定动画开始时的状态为目前画面上的样子 UIView setAnimationBeginsFromCurrentState:YES; textField.frame = CGRectMake(textField.frame.origin.x, textField.frame.origin.y + 210, textField.frame.size.width, textField.frame.size.height); UIView commitAnimations; textField addTarget:self action:selector(backgroundTap:) forControlEvents:UIControlEventTouchDown;/1.在UIView中/UITouch 的主要方法- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event if (!self.view isExclusiveTouch) newTextFiled resignFirstResponder; 2.在UIControl中/点击屏幕空白view时触发的事件 (Touch Down,Did End On Exit)- (IBAction)backgroundTap:(id)sender; - (IBAction)textFiledReturnEditing:(id)sender; /用户当前正在与之交互的控件( First Responder )textField resignFirstResponder;/通知文本失去第一响应者状态/ return键 收键盘- (IBAction)closekeyBord:(id)sender sender resignFirstResponder;/ picker / 定义property (retain, nonatomic) IBOutlet UIPickerView *typePicker;- (IBAction)showPicker CGRect screen = self.view.frame; CGSize pickersize = self.typePicker sizeThatFits:CGSizeZero; CGRect size = CGRectMake(0, screen.origin.y + screen.size.height - datePicker.frame.size.height, pickersize.width, pickersize.height); self.datePicker.frame = size; self.view addSubview:datePicker;- (IBAction)closePicker CGRect screen = self.view.frame; CGSize pickersize = self.datePicker sizeThatFits:CGSizeZero; CGRect size = CGRectMake(0, screen.origin.y + screen.size.height + datePicker.frame.size.height, pickersize.width, pickersize.height); self.datePicker.frame = size; datePicker removeFromSuperview;/ picker动画CGRect screen = self.view.frame; CGSize pickerSize = self.typePicker sizeThatFits:CGSizeZero; /set animations start position and end position CGRect size1 = CGRectMake(0.0, screen.origin.y+screen.size.height+pickerSize.height, pickerSize.width,pickerSize.height); CGRect size2 = CGRectMake(0.0, screen.origin.y+screen.size.height-pickerSize.height, pickerSize.width,pickerSize.height); self.typePicker.frame = size1; /animation begin UIView beginAnimations:nil context:NULL; /set animations speed UIView setAnimationDuration:0.3; UIView setAnimationDelegate:self; UIView setAnimationBeginsFromCurrentState:YES; self.typePicker.frame = size2; /show the picker self.view addSubview:typePicker; /animation end UIView commitAnimations;/自定义picker/ returns the number of columns to display.- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView return 2;/ returns the # of rows in each component.- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component if (component=0) return cityArray count; else return nameArray count; - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component if (component=0) return cityArray objectAtIndex:row; else return nameArray objectAtIndex:row; / 返回首页-(IBAction)backTop self.navigationController popToViewController:self.navigationController.viewControllers objectAtIndex:0 animated:YES;/ 返回按钮 UIBarButtonItem *backButton = UIBarButtonItem alloc initWithTitle:返回 style:UIBarButtonItemStyleBordered target:nil action:nil; self.navigationItem setBackBarButtonItem:backButton;/ ta

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论