我正在尝试找出我的应用出了什么问题。它在 Release模式下崩溃 EXC_BAD_ACCESS,但是当我尝试检查僵尸时,它不会通过仪器崩溃。毫无疑问,我关闭了僵尸检测并且它崩溃了。
当它确实崩溃时,我唯一能说的是 vm 分配中的最新调用显示了这个 viewDidLoad。所以我想知道这里有什么问题吗?
- (void)viewDidLoad
{
[super viewDidLoad];
//load abstract
if ( self.abstractId > 0 ){
[self startQueryselector(getAbstractWithId];
}
//setup nav bar
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle"" style:UIBarButtonItemStylePlain target:nil action:nil];
[self.view addSubview:[self makeFavoriteButton]];
//add link attributes
self.linkAttributes = @{NSForegroundColorAttributeName: [UIColor colorWithHexString:emaGreen],
NSUnderlineColorAttributeName: [UIColor lightGrayColor],
NSUnderlineStyleAttributeName: @(NSUnderlinePatternSolid)};
//create text view
UITextView *tv = [[UITextView alloc] initWithFrame:self.view.frame];
tv.editable = NO;
tv.textAlignment = NSTextAlignmentLeft;
tv.text = @" ";
tv.backgroundColor = [UIColor whiteColor];
tv.scrollEnabled = YES;
tv.dataDetectorTypes = UIDataDetectorTypeLink;
tv.linkTextAttributes = self.linkAttributes; // customizes the appearance of links
tv.delegate = self;
// set the scroll indicators between nav and tabs
tv.scrollIndicatorInsets = UIEdgeInsetsMake(0,
0,
CGRectGetHeight(self.tabBarController.tabBar.frame),
0);
//add to property and view
self.tv = tv;
[self.view addSubview:tv];
//Create spinner view
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
self.hud = hud;
}
我还有哪些其他调试选项?
谢谢!
Best Answer-推荐答案 strong>
我猜是这一行:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle""style:UIBarButtonItemStylePlain target:nil action:nil];
UIControl 的参数引用文档:
target: The target object—that is, the object to which the action message is sent. If this is nil, the responder chain is searched for an object willing to respond to the action message
action: A selector identifying an action message. It cannot be NULL
奇怪的是,这不是为 UIBarButtonItem 的初始化程序指定的,但我看不出为什么它也不应该是真的,除非该类实际上检查这些参数是否为 null 并做出相应的行为。
也许您的条形按钮项目正试图访问 null 选择器来发送它并在那里崩溃,或者正试图将它发送到某个已被释放的对象。这可能只有通过一些优化才能实现——例如,也许在 Release模式下,按钮会抓取一个指针,指向将由消息发送调用的函数,而不是发送消息,作为一种优化。
至少,传递 nil 似乎是错误的。
关于ios - 应用程序在 Release模式下崩溃,但在启用僵尸时不会崩溃,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/33978604/
|