看网上很多人没有找到这个方法,有个老外用的是一个私有的类,但他警告过了,当心你的程序进不了appStore, 打开UIAlertView.h头文件,苹果公司明确写了这么几句:
// hides alert sheet or popup. use this method when you need to explicitly dismiss the alert.
// it does not need to be called if the user presses on a button
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
请看第一句就知道如何用自己的代码消失了:
hides alert sheet or popup. use this method when you need to explicitly dismiss the alert.
当你想明确地(明确就是指用代码显式地)让alert消失,用来隐藏alert/sheet 弹出式的view.
使用方法:
UIAlertView* alertView=[[UIAlertView alloc] init......];
[alertView dismissWithClickedButtonIndex:0 animated:YESorNO];
失