0

I'm trying to develop an app (game) with this architecture:

  • Main view is a naviagtioncontroller based with navbar hidden
  • in Main view I need a light info button to show a options/credits flipsideview
  • this flipsideview must have another navigationcotroller with a right bar button to a "Done" system button

The problem is that the flipsideview doesn't show the done button and it seems to show the Main navigation controller...

This is the code.

AppDelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    // Override point for customization after application launch.
    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    return YES;

}

Main View (loaded from a XIB). Extract only of showInfo:

-(IBAction) showInfo:(id)sender {

    FlipSideViewController *controller = [[FlipSideViewController alloc] initWithNibName:@"FlipSideView" bundle:nil];
    controller.delegate = self;
    controller.title = @"Info";

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
    navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    navController.navigationBar.barStyle = UIBarStyleBlackOpaque;
    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleDone 
                                                                                target:controller action:@selector(done:)];

    navController.navigationItem.rightBarButtonItem = doneButton;
    controller.navController = navController;    
    [self presentModalViewController:navController animated:YES];

    [doneButton release];
    [controller release];
    [navController release];

}



- (void)flipsideViewControllerDidFinish:(FlipSideViewController *)controller {
    [self dismissModalViewControllerAnimated:YES];
}

FlipSideView. In the XIB I've only a blank view with outlet linked to the UIViewController view.

@protocol FlipsideViewControllerDelegate;

@interface FlipSideViewController : UIViewController {

    id <FlipsideViewControllerDelegate> delegate;

    UINavigationController *navController;

}


@property (nonatomic,assign) id <FlipsideViewControllerDelegate> delegate;
@property (nonatomic,retain) UINavigationController *navController;

-(IBAction)done;

@end

@protocol FlipsideViewControllerDelegate
- (void)flipsideViewControllerDidFinish:(FlipSideViewController *)controller;
@end

}

Implementation file...

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navController.navigationItem.title = @"Pippo";
}


    #pragma mark - User Methods

    - (IBAction)done {

        [self.delegate flipsideViewControllerDidFinish:self];

    }

The result is:

  • Main View showing without navigation bar
  • Click on info button
  • Flipsideview showing with animation and navigation bar with title "Info" and not "pippo and not "Done" button on the right...

Where am I wrong??

Napoleone1981
  • 107
  • 2
  • 10
  • Ok, i resolved moving the creation and assigning "Done" button into the viewDidLoad of FlipSide and, there, using self.navigationItem.XXX and self.navigationBar.XXX instead of self.navController.XXX. – Napoleone1981 Apr 27 '11 at 22:00

1 Answers1

0

Don't you get two navigationBar with navigationItems on FlipsideViewController? I am fighting with this bug now.

Liangjun
  • 601
  • 4
  • 13
  • Weel, it seems no. The only strange behaviour is that the first navigation bar is visible during the transation between flipside and main view... even if I se in viewWillAppear and viewDidDisappear the navigationBarHidden to true. After the transition the main navigation bar is no more visible, lik I want. – Napoleone1981 May 02 '11 at 19:26