开发者

UINavigationController based app with FlipSideView with another UINavigationController

开发者 https://www.devze.com 2023-03-01 16:51 出处:网络
I\'m trying to develop an app (game) with this architecture: Main view is a naviagtioncontroller based with navbar hidden

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;
    navControlle开发者_JAVA百科r.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??


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

0

精彩评论

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

关注公众号