Hide UIAlertView programmatically?

2019-04-03 01:42发布

问题:

Is there a way to hide UIAlertView programmatically? Actually I have added a UITextField in UIAlertView and I want to perform the same operation as on "Ok" button press when a user hits the keyboard return key.

回答1:

Call

[theAlertView dismissWithClickedButtonIndex:0 animated:YES];

when you handle the return key.