开发者

Help with navigation Controller, windows & subviews!

开发者 https://www.devze.com 2023-01-06 18:28 出处:网络
my first xib contains a ScrollView with a springboard like interface in MainWindow.xib: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

my first xib contains a ScrollView with a springboard like interface in MainWindow.xib:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
     navController = [[UINavigationController alloc] init];

[navController setNavigationBarHidden:YES]; [window addSubview:navController.view]; [window sendSubviewToBack:navController.view]; }

When a button is clicked the FirstViewController appears with a tableview and a navigation controller:

    - (void) buttonPushed:(id)sender {
       F开发者_如何学GoirstViewController *firstViewController = [[FirstViewController alloc] init];
       [navController pushViewController:firstViewController animated:YES];
[firstViewController release];


[window addSubview:navController.view]; }

When I click the back button in Navigation Controller to go back to springboard, I get the springboard xib, but unresponsive to touches with a Navigation Bar on top!

- (void)goHome:(id) sender { 
[self.view removeFromSuperview];

How can I go back to springboard screen (mainwindow.xib) without having the navigation bar stacked on top, and be responsive to touches ?


Why don't you set the springboard view to be the root view controller of your navigation controller and get rid of any UI in the window?

I think that the window shouldn't have any UI elements accept view of view controllers that are added to it (by navigation controller or by tab bar controller).

This way you won't have to reinvent the wheel for the first view to load from the springboard view and the back button will work properly.

You can set the navigationBarHidden property to false in the viewDidLoad method of the root view controller (the view controller of the springboard view).


Did you try calling [navController setNavigationBarHidden:YES]; in your mainview viewWillAppear callback ?


- (void)applicationDidFinishLaunching:(UIApplication *)application

{

UIViewController *rootController = [[MyRootViewController alloc] init];

navigationController = [[UINavigationController alloc]

                            initWithRootViewController:rootController];

[rootController release];



window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[window addSubview:navigationController.view];

[window makeKeyAndVisible];

}

0

精彩评论

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