你最好在你的應用程序委託中做它,當然不會將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