Objective c iOS7上的UIAlertView崩溃私有方法
堆栈如下所示,如何修复此崩溃? 它只存在于iOS7中,为什么堆栈中有uitableviewObjective c iOS7上的UIAlertView崩溃私有方法,objective-c,ios7,crash,uialertview,Objective C,Ios7,Crash,Uialertview,堆栈如下所示,如何修复此崩溃? 它只存在于iOS7中,为什么堆栈中有uitableview 0 libobjc.A.dylib objc_msgSend + 5 1 UIKit -[UIAlertView(Private) modalItem:shouldDismissForButtonAtIndex:] + 62 2 UIKit -[_UIModalItemsCoordinator _notifyDelegateModalItem:tappedButtonAtIndex:] + 94 3 UI
0 libobjc.A.dylib objc_msgSend + 5
1 UIKit -[UIAlertView(Private) modalItem:shouldDismissForButtonAtIndex:] + 62
2 UIKit -[_UIModalItemsCoordinator _notifyDelegateModalItem:tappedButtonAtIndex:] + 94
3 UIKit -[_UIModalItemAlertContentView tableView:didSelectRowAtIndexPath:] + 894
4 UIKit -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1078
5 UIKit -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 214
6 UIKit _applyBlockToCFArrayCopiedToStack + 316
7 UIKit _afterCACommitHandler + 430
8 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
-(id)initWithIdentifier:(LTAlertMsgIdentifier)alertIdentifier
委托:(id/**/)委托
CancelButtonTile:(NSString*)CancelButtonTile
OtherButtonTiles:(NSString*)OtherButtonTiles。。。{
LTAlertMsgManager*sharedAlertMsgMgr=[LTAlertMsgManager shareAlertManageInstance];
NSString*strMsg=[sharedAlertMsgMgr GetLTAlertMsgBylerId:alertIdentifier];
if([NSString isBlankString:strMsg]){
//如果警报消息为空,则警报无效
返回零;
}
NSString*strTitle=[Sharedalertmsgrg getltAlertTitleBylerId:alertIdentifier];
if(self=[super initWithTitle:([NSString isBlankString:strTitle]?nil:strTitle)
信息:strMsg
代表:代表
取消按钮提示:取消按钮提示
其他按钮类型:无]){
va_列表参数;
va_开始(参数、其他按钮符号);
对于(NSString*arg=otherbuttonitles;arg!=nil;arg=va_arg(args,NSString*))
{
[标题为arg的自添加按钮];
}
va_端(args);
}
NSLog(@“取消按钮索引-%d”,自我取消按钮索引);
回归自我;
}
UIAlertView中的按钮是使用UITableView
实现的。这就是为什么点击按钮会触发一个表视图:didSelectRowAtIndexPath
导致此类错误的典型问题有:
@属性(非原子,赋值)id委托
,因此在解除委托时确保alertView.delegate=nil
。请向我们显示didSelectRowAtIndexPath:描述警报视图。当它崩溃时,您正在做什么。UIAlertView不用于子类化。从引用中可以看出,UIAlertView类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不能修改。@vikingosegundo True,但如果不更改视图层次结构,子类化通常会起作用。错误不是由子类化引起的。所有堆栈如下所示,我无法重现此问题。因此,我无法跟踪和修复此问题。是否仅查看警报相关代码?谢谢@user3327566您添加的代码没有问题。更重要的是如何显示警报及其委托。
- (id)initWithIdentifier:(LTAlertMsgIdentifier)alertIdentifier
delegate:(id /*<UIAlertViewDelegate>*/)delegate
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles, ... {
LTAlertMsgManager *sharedAlertMsgMgr = [LTAlertMsgManager shareAlertManageInstance];
NSString *strMsg = [sharedAlertMsgMgr getLTAlertMsgByAlertID:alertIdentifier];
if ([NSString isBlankString:strMsg]){
// alert is invalid, if alert message is empty
return nil;
}
NSString *strTitle = [sharedAlertMsgMgr getLTAlertTitleByAlertID:alertIdentifier];
if (self = [super initWithTitle:([NSString isBlankString:strTitle] ? nil : strTitle)
message:strMsg
delegate:delegate
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:nil]){
va_list args;
va_start(args, otherButtonTitles);
for (NSString *arg = otherButtonTitles; arg != nil; arg = va_arg(args, NSString*))
{
[self addButtonWithTitle:arg];
}
va_end(args);
}
NSLog(@"cancel button index - %d", self.cancelButtonIndex);
return self;
}