iPhone App里弹出输入面板案例实现是本文要介绍的内容,主要是来学习输入面板功能的是实现,如果需要在您的iPhone App里加入文字输入面板功能,喜欢游戏的朋友们都明白,比如游戏破纪录后输入玩家名字。具体输入面板功能的实现来看本文详细内容。
在.h里先宣告
- UITextField *yourtextfield;
- @property (nonatomic, retain, readonly) UITextField yourtextfield;
在.m里
- @synthesize yourtextfield;
然后自己加上
- - (UITextField *)yourtextfield
- {
- if (yourtextfield == nil)
- {
- CGRect frame = CGRectMake(x, y, width, height); //textfield的位置大小
- yourtextfield = [[UITextField alloc] initWithFrame:frame];
- yourtextfield.enabled = TRUE;
- yourtextfield.borderStyle = UITextBorderStyleNone;
- yourtextfield.textColor = [UIColor blackColor];
- yourtextfield.font = [UIFont systemFontOfSize:14.0];
- yourtextfield.placeholder = @"user name";
- yourtextfield.backgroundColor = [UIColor whiteColor];
- yourtextfield.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
- yourtextfield.keyboardType = UIKeyboardTypeDefault; // 一般的键盘style
- yourtextfield.returnKeyType = UIReturnKeyDone;
- yourtextfield.clearButtonMode = UITextFieldViewModeWhileEditing; //可以一次清除输入中的文字
- yourtextfield.tag = kViewTag; // tag this control so we can remove it later for recycled cells
- textFieldNormalyourtextfield.delegate = self; // 让user输入完,按下done 键盘会自动收起来
- // Add an accessibility label that describes what the text field is for.
- [yourtextfield setAccessibilityLabel:NSLocalizedString(@"username", @"")];
- }
- return yourtextfield;
- }
最后要在dealloc 中release
- [yourtextfield release];
小结:iPhone App里弹出输入面板案例实现的内容介绍完了,希望通过本文的学习能对你有所帮助!