當我點擊TTTabBar時,選中的選項卡發送給我一個正確的ViewController,然後我點擊另一個TTTabBar它會將我發送給另一個..... etc,但我該如何刪除最後一個ViewController,所以它們不會一直堆疊在一起。刪除未使用的ViewControllers
- (void)tabBar:(TTTabBar*)tabBar tabSelected:(NSInteger)selectedIndex
{
if(selectedIndex == 0){
UIViewController* viewController = (UIViewController*)[[TTNavigator navigator] viewControllerForURL:@"tt://Forum"];
[self.view addSubview:viewController.view];
[self.view addSubview:_tabBar];
}else if(selectedIndex == 1) {
UIViewController* viewController = (UIViewController*)[[TTNavigator navigator] viewControllerForURL:@"tt://Profile"];
[self.view addSubview:viewController.view];
[self.view addSubview:_tabBar];
}else if(selectedIndex == 2) {
UIViewController* viewController = (UIViewController*)[[TTNavigator navigator] viewControllerForURL:@"tt://PMs"];
[self.view addSubview:viewController.view];
[self.view addSubview:_tabBar];
}else if(selectedIndex == 3) {
UIViewController* viewController = (UIViewController*)[[TTNavigator navigator] viewControllerForURL:@"tt://Friends"];
[self.view addSubview:viewController.view];
[self.view addSubview:_tabBar];
}
}
我得到這個工作
if ([viewController isKindOfClass:[UIViewController class]]) {
[viewController.view removeFromSuperview];
} else {
}
當我將它上面
if(selectedIndex == 0){
if([viewController isKindOfClass:[UIViewController class]]){ \t \t [viewController.view removeFromSuperview]; \t}其他{ \t \t \t} – Duny 2011-03-17 01:21:32
謝謝,我添加了什麼我得到了工作上面 – Duny 2011-03-17 01:24:02