IBAction导致EXC_BAD_ACCESS错误

时间:2013-02-14 07:07:29

标签: ios objective-c button exc-bad-access ibaction

我加载了一个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];

这是我映射它的方式:

http://i.picresize.com/images/2013/02/13/T2AHc.png

但是按下按钮后,我得到的是EXC_BAD_ACCESS错误,我得到了这个输出:

(lldb)

EXC_BAD_ACCESS错误。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

-(IBAction)donePressed:(id)sender
{
printf("Done\n");
printf("Removing View\n");
[moviePlayer_af.view removeFromSuperview];
}