UIView将移动ToTTuperview错误

时间:2010-08-01 21:55:04

标签: objective-c xcode interface

我在iPhone上运行应用程序时出现此随机错误。

首先,我点按这个方法 -

-(IBAction)playBeat1 {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"beat1" ofType:@"mp3"];
    AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; 

    [theAudio play];
    NSLog(@"Beatmaker");    
}

然后当我点击它(它更改视图) -

-(IBAction) back{   
    [self dismissModalViewControllerAnimated:YES];
}

我收到此错误

UIView willMoveToSuperview:]:发送到解除分配的实例0x1b1a20的消息

任何想法?

1 个答案:

答案 0 :(得分:3)

您正在解雇已取消分配的模态视图控制器。处理此问题的最佳方法是激活NSZombies(搜索SO)。但是,如果您向我们展示您提供模态视图的位置,我们可能会给您更多建议。我的猜测是你应该使用它:

[self.parentViewController dismissModalViewControllerAnimated:YES];

但我必须看到更多代码才能知道。

playBeat1似乎与您的问题无关。