Vin*_*nce 4 iphone uialertview ipad ios5
当我调用UIAlertView的dismissWithClickedButtonIndex:animated:时,我遇到了一个问题,其中9次出现问题,委托方法alertView:willDismissWithButtonIndex:未被调用.还有其他人遇到这个问题吗?我即将向Apple提交一个错误,但我很想知道是否有其他人遇到过这个问题,并想出任何解决方法.
为了确保iOS4和5之间的一致行为,您可以在调用其dismissWithClickedButtonIndex:animated:方法之前删除UIAlertView的委托,然后手动调用委托方法.例如
- (void)somethingDidHappen {
id<UIAlertViewDelegate> delegate = myAlertView.delegate;
myAlertView.delegate = nil;
// now, we know the delegate won't be called...
[myAlertView dismissWithClickedButtonIndex:0 animated:NO];
// ...so we call it ourselves below
[delegate alertView:myAlertView clickedButtonAtIndex:0];
}
Run Code Online (Sandbox Code Playgroud)
(该代码未经过测试,但您明白了.)
| 归档时间: |
|
| 查看次数: |
5037 次 |
| 最近记录: |