开发者

UIView not responding to touches after 'removeFromSuperview'

In my app delegate, I am creating a tab controller with a bunch of view controllers for it and then a separate UIViewController that I show as the top-most view until the user performs a certain action.

I'm initially covering up my tab controller with the second controller but eventually, the second controller is dismissed via 'removeFromSuperview'. However, after this happens, the tab controller view won't respond to any taps or any UI interaction. My app isn't hung as I can see the processing happen.

Is there a way to make the tab controller become the de-facto responder after the topmost view is dismissed?

Here's how I initially create both view controllers:

{
// main navigation controller is a tab bar
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects: controller开发者_如何学Go1, 
                                    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];
}

How the top most view is dismissed:

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

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

I don't want the top most view to look like I was adding a modal dialog and would like the screen to be there as soon as the app is launched.


I think your tabbar view is still "2nd" in the list. Have you tried adding:

bringSubviewToFront:

Moves the specified subview to the front of its siblings. - (void)bringSubviewToFront:(UIView *)view Parameters view The subview to move to the front. Availability * Available in iPhone OS 2.0 and later. See Also * – sendSubviewToBack: Declared In UIView.h

If that doesn't help, you may need to set your tabbar as First Responder.

- (BOOL)canBecomeFirstResponder {
     returnYES;
}

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜