【问题标题】:call method from another class generating SIGABRT error on xcode从另一个类调用方法在 xcode 上生成 SIGABRT 错误
【发布时间】:2011-08-28 13:58:30
【问题描述】:

我正在调用包含在必须更改视图的控制器类中的方法。它会在 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];
}

【问题讨论】:

  • 在将它作为子视图插入之前检查 controladorAjusted.view 的值。有没有可能是零?
  • 是的,它是零。调用该方法的类的视图必须在方法执行时被删除,这可能是个问题吗?
  • 好的,解决了,只是调用xib的时候出现的!名称不正确。谢谢。

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


【解决方案1】:

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

如果您正在做某事将视图显式设置为 nil,那么您可能没有采取正确的方法。我怀疑您在调用以下内容时做了一些可疑的事情:

  [self.controladorAjustes viewWillAppear:YES];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多