J'essaie d'implémenter un UINavigationController
de base et je rencontre un problème avec le contrôleur de navigation affichant une mauvaise vue.UINavigationController affichant la mauvaise vue
J'ai commencé par la création d'un Window Based Application
dans Xcode 4
qui m'a donné les fichiers suivants: spellingAppDelegate.h
, spellingAppDelegate.m
et MainWindows.xib
. J'ai ensuite ajouté une nouvelle sous-classe UIViewController
et l'appeler gameViewController
.
Ce qui suit est mon code pour myAppDelegate.h
#import <UIKit/UIKit.h>
@interface spellingAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UINavigationController *navigationController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UINavigationController *navigationController;
@end
ce qui suit est mon myAppDelegate.m
#import "spellingAppDelegate.h"
#import "gameViewController.h"
#import "resultViewController.h"
@implementation spellingAppDelegate
@synthesize window = window;
@synthesize navigationController = navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self.window makeKeyAndVisible];
// create the MyView controller instance:
gameViewController *controller = [[gameViewController alloc] initWithNibName:@"gameViewController" bundle:nil];
// set the title that appears in the navigation bar:
[controller.navigationItem setTitle:@"Main View"];
// create the Navigation Controller instance:
UINavigationController *newnav = [[UINavigationController alloc] initWithRootViewController:controller];
// set the navController property:
[self setNavigationController:newnav];
// release both controllers:
[newnav release];
[controller release];
// add the Navigation Controller's view to the window:
[window addSubview:[navigationController view]];
return YES;
}
J'avais l'impression que si je lance le code ci-dessus, l'application commencera par gameViewController.xib. Cependant, il affiche MainWindow.xib. Je sais que je manque probablement quelque chose de basique mais je n'arrive pas à comprendre ce que j'ai fait de mal. Je vous remercie.
merci. ça a marché. – atbebtg