Wednesday 17 July 2013

How to set UITextField Resign First responder ?

First of all assign UITextFieldDelegate in .h file Like this


@interface ViewController : UIViewController<UITextFieldDelegate>

Propertize textfield in .h file

@property (nonatomic, unsafe_unretained) IBOutlet UITextField * txtField;

Assign Delegate in viewDidLoad in .m file

self. txtField.delegate = self;

Add this Method in .m file

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if(textField==selftxtField )
    {
        [self. txtField resignFirstResponder];
        return NO;
    }
    return YES;
}
Ads: ebay

No comments:

Post a Comment