2010-01-24 45 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