来自另一个类的调用方法在xcode上生成SIGABRT错误

时间:2011-08-28 13:58:31

标签: iphone objective-c xcode cocoa-touch uitableview

我正在调用控制器类中包含的必须更改视图的方法。它会在insertsubview.view上生成错误。怎么解决?谢谢

从当前menuViewController类调用:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{    
     aboutTabController * myObject = [[aboutTabController alloc] init];

    if (indexPath.section == 1) {

        switch (indexPath.row) {
            case 0:
                [myObject turnIdioma];
                break;
            case 1:
                //
                break;
            default:
            break;}
    }

}

//method implememented in controller class:

- (void) turnIdioma
{


     [UIView beginAnimations:@"View Flip" context:nil];
        [UIView setAnimationDuration:1.0];
        [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    if (self.controladorAjustes == nil)
    {
        settingsViewController *aController = [[settingsViewController alloc] initWithNibName:@"mailViewController" bundle:nil];
        self.controladorAjustes = aController;
        [aController release];
    }

    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

    [self.controladorMenu viewWillDisappear:YES];
    [self.controladorAjustes viewWillAppear:YES];

    [self.controladorMenu.view removeFromSuperview];
    [self.view insertSubview:controladorAjustes.view    atIndex:0];

    [self.controladorMenu viewDidDisappear:YES];
    [self.controladorAjustes viewDidAppear:YES];

    [UIView commitAnimations];
}

1 个答案:

答案 0 :(得分:0)

您不能将零值对象作为子视图插入。通常,视图控制器将确保在您尝试获取其视图属性时使用适当的方法创建它,具体取决于它是否是由NIB文件定义的视图。

如果你正在做一些事情来明确地将视图设置为nil那么你可能没有采取正确的方法。我怀疑你在打电话的时候做了一些可疑的事情:

  [self.controladorAjustes viewWillAppear:YES];