2010-01-24 93 views
2

以我的應用程序委託後的UIView不響應的觸摸,直到用戶執行我創建與一羣視圖控制器,用於它的再一個單獨的UIViewController我顯示爲最上面的視圖選項卡控制器某些行動。「removeFromSuperview」

我最初覆蓋了我的第二個控制器選項卡控制器,但最終,第二控制器通過「removeFromSuperview」駁回。但是,在發生這種情況後,選項卡控制器視圖將不會響應任何點擊或任何UI交互。我的應用程序沒有掛起,因爲我可以看到處理髮生。

有沒有一種方法,使成爲事實上的應答器選項卡控制器最上面的觀點是駁回後?

以下是我最初創建兩個視圖控制器:

{ 
// main navigation controller is a tab bar 
UITabBarController *tabBarController = [[UITabBarController alloc] init]; 
tabBarController.viewControllers = [NSArray arrayWithObjects: controller1, 
            controller2, 
            controller3, nil]; 

// Add the tab bar to the view 
[window addSubview:tabBarController.view]; 


// Creating the 2nd navigation controller - covering up the tab bar 
// temporarily 
UIViewController *viewController = [[MySecondViewController alloc] 
             initWithNibName:@"SomeView" 
             bundle:nil]; 

UINavigationController *navController = [[UINavigationController alloc] 
      initWithRootViewController:viewController]; 

[viewController release]; 

// Configure and show the second navigation controller 
[window addSubview:[navController view]];  

// Make everything visible 
[window makeKeyAndVisible]; 
} 

如何最頂部的視圖被駁回:

@interface MySecondViewController : UIViewController 
{ 
} 
-(void)dismissMe; 
@end 

@implementation MySecondViewController 
-(void)dismissMe 
{ 
    // Here, the this view is getting removed 
    [self.view removeFromSuperview];   
} 
@end 

我不想最頂部的視圖的樣子,我加入一個模式對話框,並希望屏幕在應用程序啓動後立即到場。

回答

0

我覺得你的TabBar視圖仍然在列表中的「第二」。您是否嘗試過加入:

bringSubviewToFront

移動指定的子視圖到 前面的兄弟姐妹。 - (void)bringSubviewToFront:(UIView *)view參數視圖 子視圖移動到前面。供貨情況 *適用於iPhone OS 2.0及更高版本。另請參見 * - sendSubviewToBack:宣佈UIView.h

如果沒有幫助,您可能需要設置你的TabBar作爲急救員。

- (BOOL)canBecomeFirstResponder { 
    returnYES; 
} 

- (void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 
    [self becomeFirstResponder]; 
} 
+0

我試過這些,但沒有工作;但是它給了我一個嘗試別的東西的想法,這是成功的。我提出的UIWindow類交換dismissMe視圖像這樣: [appDelegate.window exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; \t \t \t \t [appDelegate.tabBarController.view becomeFirstResponder]; 除了這導致了另一個問題,其中狀態欄中的UIButton項目不會響應啓用/禁用。爲此發佈一個單獨的問題。 – 2010-01-24 19:30:34