iPhone App里彈出輸入面板案例實(shí)現(xiàn)
作者:佚名
iPhone App里彈出輸入面板案例實(shí)現(xiàn)是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)輸入面板功能的是實(shí)現(xiàn),如果需要在您的iPhone App里加入文字輸入面板功能。
iPhone App里彈出輸入面板案例實(shí)現(xiàn)是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)輸入面板功能的是實(shí)現(xiàn),如果需要在您的iPhone App里加入文字輸入面板功能,喜歡游戲的朋友們都明白,比如游戲破紀(jì)錄后輸入玩家名字。具體輸入面板功能的實(shí)現(xiàn)來看本文詳細(xì)內(nèi)容。
在.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 鍵盤會(huì)自動(dòng)收起來
- // Add an accessibility label that describes what the text field is for.
- [yourtextfield setAccessibilityLabel:NSLocalizedString(@"username", @"")];
- }
- return yourtextfield;
- }
最后要在dealloc 中release
- [yourtextfield release];
小結(jié):iPhone App里彈出輸入面板案例實(shí)現(xiàn)的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!
責(zé)任編輯:zhaolei
來源:
CocoaChina