The role of each method in the Uitextfielddelegate protocol and the automatic generation of various methods in Xcode APPDELEGATE.M (IOS)

Source: Internet
Author: User

the role of each method in the Uitextfielddelegate protocol

Controls whether the current input box can be edited

-(BOOL) textfieldshouldbeginediting: ( Uitextfield *) TextField

triggered when the input box starts(Get Focus Trigger)
- (void) textfielddidbeginediting: (Uitextfield*) TextField

asks if the input box can end the edit(whether the keyboard can be retracted)
- (BOOL) textfieldshouldendediting: (Uitextfield*) TextField

triggered when the current input box finishes editing ( trigger after keyboard retract )

-(void) textfielddidendediting: ( Uitextfield *) TextField

trigger when input box text changes ( , text change , trigger )

-(BOOL) TextField: ( Uitextfield *) TextField shouldchangecharactersinrange: (nsrange) range replacementstring: ( NSString *) string


Controls whether the input box Clear button is valid(yes,have a; no,No)
- (BOOL) Textfieldshouldclear: (Uitextfield*) TextField

controls whether the keyboard is recycled-(BOOL) Textfieldshouldreturn: (Uitextfield*) TextField

how each method is automatically generated in APPDELEGATE.M in the UI

Triggered when application loading is complete

-(BOOL) application: ( uiapplication *) Application didfinishlaunchingwithoptions: (nsdictionary *) launchoptions


Triggered when an application is about to cancel active state

-(void) applicationwillresignactive: ( uiapplication *) Application


triggered when the current application has entered the background(application hangs in background)
- (void) Applicationdidenterbackground: (uiapplication*) Application

triggered when an application is going to enter the foreground(triggers when the program is about to become active)
- (void) Applicationwillenterforeground: (uiapplication*) Application

the application is already active ( currently running )

-(void) applicationdidbecomeactive: ( uiapplication *) Application

triggers when the application will end
- (void) Applicationwillterminate: (uiapplication*) Application

example of execution order of each method

As an example, the phone is running a program when suddenly the phone

program Flow when there is a telephone entry : applicationwillresignactive:

1. when rejecting

Application State : applicationdidbecomeactive:

2. pick up the phone

Application State: Applicationdidenterbackground:

Common methods for handling screen rotation

when the view controller's View when you re-layout , triggering

-(void) viewwilllayoutsubviews


used to set the current view controller,whether rotation is supported
- (BOOL) Shouldautorotate

set the orientation of the screen rotation , supports three directions , Vertical Direction , Zoo , Right Horizontal screen

-(nsuinteger) supportedinterfaceorientations

The role of each method in the Uitextfielddelegate protocol and the automatic generation of various methods in Xcode APPDELEGATE.M (IOS)

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.