【发布时间】:2013-02-14 07:07:29
【问题描述】:
我加载了一个 xib,然后我需要用一个按钮关闭它。我正在使用这个:
- (IBAction)donePressed:(id)sender {
printf("Done\n");
[self check_result];
printf("Removing View\n");
[self.view removeFromSuperview];
}
我像这样加载 XIB:
AFUserFeedbackController *moviePlayer_af = [[AFUserFeedbackController alloc] initWithNibName:@"UserFeedback" bundle:nil];
UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow];
moviePlayer_af.view.frame = backgroundWindow.frame;
[backgroundWindow addSubview:moviePlayer_af.view];
这是我的映射方式:
但按下按钮后,我得到的只是EXC_BAD_ACCESS 错误,我得到这个输出:
(lldb)
和EXC_BAD_ACCESS 错误。我该如何解决?
【问题讨论】:
-
1.
check_result是做什么的? 2.[self.view removeFromSuperview];- 哦,为什么? -
检查 IBAction 连接是否正确?你是在展示那个视图控制器吗??
-
崩溃是立即点击还是通过目标方法后发生?
-
问题是,它甚至没有达到那个点。如果它会在任何事情之前打印
Done... -
@AppleDelegate,当我点击按钮时立即发生。
标签: ios objective-c button exc-bad-access ibaction