【发布时间】: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