2011-07-26 75 views

回答

2
  1. 你必須有一個根視圖控制器
  2. 這兩種觀點之間的這根視圖控制器切換。

事情是這樣的:

- (IBAction)switchViews:(id)sender { 
if (self.vc1 == nil) { 
self.vc1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; 
[self.vc2 removeFromSuperview]; 
[self.view addSubView:vc1]; 
vc2 = nil; 
} 
else { 
self.vc2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 
[self.vc1 removeFromSuperView]; 
[self.view addSubView:vc2]; 
vc1 = nil; 
} 
} 
+1

非常感謝您! – Shawn