Afficher la première vue avec un UINavigationBar
Bonjour,
Impossible de trouver comment faire pour afficher ma première vue avec une Navigation Bar.
Donc actuellement je fait ça:
Delegate (h):
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| #import <UIKit/UIKit.h>
@interface HCAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UINavigationController *navigationController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@end |
(m):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #import "HCAppDelegate.h"
#import "MainMenuViewController.h"
@implementation HCAppDelegate
@synthesize window;
@synthesize navigationController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:navigationController.view];
} |
Controller (h):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| @interface MainMenuViewController : UIViewController {
UIWindow *window;
UIButton *newsButton;
IBOutlet UIView *newsView;
IBOutlet UIView *mainMenuView;
IBOutlet UIScrollView *currentView;
}
- (IBAction) newsButtonAction;
- (IBAction) loadMainMenuView;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic,retain) IBOutlet UIButton *newsButton;
@property (nonatomic,retain) IBOutlet UIView *newsView;
@property (nonatomic,retain) IBOutlet UIView *mainMenuView;
@property (nonatomic,retain) IBOutlet UIScrollView *currentView;
@end |
(m):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #import "MainMenuViewController.h"
@implementation MainMenuViewController
@synthesize newsButton;
@synthesize newsView;
@synthesize currentView;
@synthesize window;
@synthesize mainMenuView;
- (IBAction) newsButtonAction {
[currentView addSubview:newsView];
NSLog(@"News click");
}
- (IBAction) loadMainMenuView {
[currentView addSubview:mainMenuView];
NSLog(@"Load MainMenuView");
} |
J'aimerai donc ajouter ma vue MainMenuView dès le démarrage sur un UIScrollView (c'est le currentView).
Merci