Bonjour,
Impossible de trouver comment faire pour afficher ma première vue avec une Navigation Bar.
Donc actuellement je fait ça:
Delegate (h):
(m):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Controller (h):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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]; }
(m):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
J'aimerai donc ajouter ma vue MainMenuView dès le démarrage sur un UIScrollView (c'est le currentView).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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"); }
Merci
Partager