你最好在你的应用程序委托中做它,当然不会将UITableViewController.view添加到UIViewController.view中......只需将它添加到UIWindow中,然后解除旧的UIViewController(removeFromSuperView它的视图,然后释放它)
编辑:
这就是我如何管理:
我在的appDelegate添加一个方法:
-(void)switchMainView;
,并从我的UIViewController我只是这样称呼它:
[[[UIApplication sharedApplication] delegate] switchMainView];
在switchMainView我只是 移除上海华我UIViewController.view, 发布的UIViewController, ALLOC了的UITableViewController和初始化,然后 添加其查看该窗口的应用程序:
-(void)switchMainView{
if (mainView!=nil){ // mainView is the UIViewController
[mainView.view removeFromSuperview];
[mainView release];
mainView = nil;
}
Menu *vc; // Menu is my class, subClass of a UITableViewController
vc = [[Menu alloc] init];
nc = [[UINavigationController alloc] initWithRootViewController:vc];
[window addSubview:nc.view];
[vc release];
}
,然后我做同样的回去,最终
因此,一个伟大的方式做到这将注册在应用程序委托的通知,然后把它当用户在得到loged并再次在应用程序委托中更改视图?或者是否有可能直接从loginViewController在应用程序委托中运行方法? – tobros91 2011-03-16 10:40:22
@tobros:在我的回答 – meronix 2011-03-16 10:54:08
中看到我的新编辑,谢谢你做到了! – tobros91 2011-03-16 11:39:13