Case study of pop-up Input Panel in iPhone App

Source: Internet
Author: User

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

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

In. m

 
 
  1. @synthesize yourtextfield; 

Add

 
 
  1. -(UITextField *) yourtextfield
  2. {
  3.  
  4. If (yourtextfield = nil)
  5. {
  6. CGRect frame = CGRectMake (x, y, width, height); // The position and size of 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. Yourtextfield. keyboardType = UIKeyboardTypeDefault; // General keyboard style
  16. Yourtextfield. returnKeyType = UIReturnKeyDone;
  17. Yourtextfield. clearButtonMode = UITextFieldViewModeWhileEditing; // you can clear the text in the input at a time.
  18. Yourtextfield. tag = kViewTag; // tag this control so we can remove it later for recycled cells
  19. TextFieldNormalyourtextfield. delegate = self; // After the user is input, press the done keyboard to automatically collect it.
  20. // Add an accessibility label that describes what the text field is.
  21. [Yourtextfield setAccessibilityLabel: NSLocalizedString (@ "username", @ "")];
  22. }
  23. Return yourtextfield;
  24. }

Finally, in dealloc, release

 
 
  1. [yourtextfield release]; 

Summary:IPhone AppPop-upInput PanelThe implementation of the case is complete. I hope this article will help you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.