iPhone App里弹出输入面板案例实现

移动开发 iOS
iPhone App里弹出输入面板案例实现是本文要介绍的内容,主要是来学习输入面板功能的是实现,如果需要在您的iPhone App里加入文字输入面板功能。

iPhone App里弹出输入面板案例实现是本文要介绍的内容,主要是来学习输入面板功能的是实现,如果需要在您的iPhone App里加入文字输入面板功能,喜欢游戏的朋友们都明白,比如游戏破纪录后输入玩家名字。具体输入面板功能的实现来看本文详细内容。

在.h里先宣告

  1. UITextField *yourtextfield;  
  2. @property (nonatomic, retain, readonly) UITextField yourtextfield; 

在.m里

  1. @synthesize yourtextfield; 

然后自己加上

  1. - (UITextField *)yourtextfield  
  2. {  
  3.  
  4. if (yourtextfield == nil)  
  5.     {  
  6.         CGRect frame = CGRectMake(x, y, width, height);         //textfield的位置大小  
  7.         yourtextfield = [[UITextField alloc] initWithFrame:frame];  
  8.         yourtextfield.enabled = TRUE;  
  9.         yourtextfield.borderStyle = UITextBorderStyleNone;  
  10.         yourtextfield.textColor = [UIColor blackColor];  
  11.         yourtextfield.font = [UIFont systemFontOfSize:14.0];  
  12.         yourtextfield.placeholder = @"user name";  
  13.         yourtextfield.backgroundColor = [UIColor whiteColor];  
  14.         yourtextfield.autocorrectionType = UITextAutocorrectionTypeNo;    // no auto correction support  
  15.          
  16.         yourtextfield.keyboardType = UIKeyboardTypeDefault;    // 一般的键盘style  
  17.         yourtextfield.returnKeyType = UIReturnKeyDone;  
  18.          
  19.         yourtextfield.clearButtonMode = UITextFieldViewModeWhileEditing;     //可以一次清除输入中的文字  
  20.          
  21.         yourtextfield.tag = kViewTag;        // tag this control so we can remove it later for recycled cells  
  22.          
  23.         textFieldNormalyourtextfield.delegate = self;    // 让user输入完,按下done 键盘会自动收起来  
  24.          
  25.         // Add an accessibility label that describes what the text field is for.  
  26.         [yourtextfield setAccessibilityLabel:NSLocalizedString(@"username", @"")];  
  27.     }     
  28.     return yourtextfield;  

最后要在dealloc 中release

  1. [yourtextfield release]; 

小结:iPhone App里弹出输入面板案例实现的内容介绍完了,希望通过本文的学习能对你有所帮助!

责任编辑:zhaolei 来源: CocoaChina
相关推荐

2011-07-22 17:24:46

iPhone 视图

2011-08-15 15:44:46

iPhone开发PDF

2011-08-18 15:40:20

iPhone文本切页

2011-08-18 16:24:44

iPhone开发图片

2011-08-19 10:13:05

iPhone开发

2011-08-19 11:10:31

iPhone应用

2011-08-16 15:48:37

iPhone开发抓图程序

2011-08-17 16:12:20

iPhone应用程序

2011-08-17 16:23:31

iPhone开发UIViewContr

2011-08-16 15:36:47

iPhone应用测试

2011-08-18 15:24:40

iPhone国际化

2011-08-19 10:05:30

iPhone开发

2011-08-19 10:01:09

iPhone应用SqliteUITableView

2011-08-17 16:29:12

iPhone开发UIButton

2011-08-18 16:42:07

iPhone应用APNS推送

2011-08-03 17:44:57

iPhone App 文件

2011-08-18 16:03:34

iPhone上传图片

2011-08-19 09:54:40

iPhone开发电子书字符串

2011-07-29 14:18:46

iPhone开发 动画

2011-08-16 14:54:12

iphone开发APP
点赞
收藏

51CTO技术栈公众号