我得到这个下面的例外,同时提示用户UIAlertView中崩溃
0 CoreFoundation __exceptionPreprocess + 130
1 libobjc.A.dylib objc_exception_throw + 38
2 CoreFoundation -[NSObject(NSObject) doesNotRecognizeSelector:] + 202
3 CoreFoundation ___forwarding___ + 706
4 CoreFoundation _CF_forwarding_prep_0 + 24
5 UIKit -[_UIModalItem setMessage:] + 40
6 UIKit -[_UIModalItem initWithTitle:message:otherButtonTitles:completion:delegate:] + 102
7 UIKit +[_UIModalItem modalItemWithType:title:message:buttonTitles:completion:] + 76
8 UIKit -[UIAlertView _modalItemForNeueCompatibility] + 362
9 UIKit -[UIAlertView popupAlertAnimated:animationType:atOffset:] + 56
10 UIKit -[UIAlertView popupAlertAnimated:animationType:] + 34
我写的警报视图代码的方法在我的实用工具类的一个
+(void)showAlertWithTitle:(NSString*)title message:(NSString*)msg cancelButtonTitle:(NSString*)canceltitle confirmBtnTitle:(NSString*)cnftitle andTag:(int)alertTag andDelegate:(id)ref{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:title message:msg delegate:ref cancelButtonTitle:canceltitle otherButtonTitles:cnftitle, nil];
alertView.tag = alertTag;
[alertView show];
}
予实现的相同代码并能正常工作。您是否为objective-c异常设置了断点? – Mike 2014-08-27 22:04:39
警报解除后是否存在'ref'? – rebello95 2014-08-27 22:11:01
其实我会在需要执行任何操作时传递'ref'。否则'ref'将是'nil'意味着没有委托。 – 2014-08-27 22:18:47