开发者

dismiss modal view with return key

开发者 https://www.devze.com 2023-01-21 08:20 出处:网络
I got one UITextField on my Modal view controller. When \"Done\" key is clicked, 开发者_Python百科i want to dismiss the modal view.

I got one UITextField on my Modal view controller. When "Done" key is clicked, 开发者_Python百科i want to dismiss the modal view. i don't know where should i add below code to dismiss modal view. Thanks in advance for any help.

[self.parentViewController dismissModalViewControllerAnimated:YES];


add it in UITextFieldDelegate method

-(BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    [self.parentViewController dismissModalViewControllerAnimated:YES];
    return YES;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消