2011-08-28 66 views
0

我正在调用一个包含在控制器类中的方法,该方法必须更改视图。它在insertsubview.view上产生一个错误。如何解决它?感谢您从当前menuViewController类来自另一个类的调用方法在xcode上产生SIGABRT错误

电话:

- (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]; 
} 
+0

在将它作为子视图插入之前,请检查controladorAjusted.view的值。它可能是零吗? –

+0

是的,它是零。方法执行时,必须移除调用该方法的类的视图,这是否会成为问题? – Ruth85

+0

好的,解决了,只是在调用xib的时候!名字不正确。谢谢。 – Ruth85

回答

0

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

如果你正在做一些明确的设置视图为零,那么你可能没有采取正确的做法。我怀疑你正在做一些可疑的内容,请致电:

[self.controladorAjustes viewWillAppear:YES];