IPhone AppPop-upInput PanelThe implementation of the case is the content to be introduced in this article, mainly to learn how to implement the Input Panel function, if you needIPhone AppThe text input panel function is added to the game, and friends who like the game understand it. For example, after the game breaks the record, enter the player name. DetailsInput PanelFor more information about the function implementation, see this article.
Declare in. h
- UITextField *yourtextfield;
- @property (nonatomic, retain, readonly) UITextField yourtextfield;
In. m
- @synthesize yourtextfield;
Add
- -(UITextField *) yourtextfield
- {
-
- If (yourtextfield = nil)
- {
- CGRect frame = CGRectMake (x, y, width, height); // The position and size of 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; // General keyboard style
- Yourtextfield. returnKeyType = UIReturnKeyDone;
- Yourtextfield. clearButtonMode = UITextFieldViewModeWhileEditing; // you can clear the text in the input at a time.
- Yourtextfield. tag = kViewTag; // tag this control so we can remove it later for recycled cells
- TextFieldNormalyourtextfield. delegate = self; // After the user is input, press the done keyboard to automatically collect it.
- // Add an accessibility label that describes what the text field is.
- [Yourtextfield setAccessibilityLabel: NSLocalizedString (@ "username", @ "")];
- }
- Return yourtextfield;
- }
Finally, in dealloc, release
- [yourtextfield release];
Summary:IPhone AppPop-upInput PanelThe implementation of the case is complete. I hope this article will help you!