我在AppDelegate
下面的代碼:的UINavigationController pushViewController在viewDidLoad中不工作
#import <UIKit/UIKit.h>
@class PersonalDiarySystemViewController;
@interface PersonalDiarySystemAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
PersonalDiarySystemViewController *viewController;
UINavigationController *navigationController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet PersonalDiarySystemViewController *viewController;
@property (nonatomic, retain) UINavigationController *navigationController;
@end
#import "PersonalDiarySystemAppDelegate.h"
#import "PersonalDiarySystemViewController.h"
@implementation PersonalDiarySystemAppDelegate
@synthesize window;
@synthesize viewController;
@synthesize navigationController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Set the view controller as the window's root view controller and display.
self.window.rootViewController = self.viewController;
navigationController = [[UINavigationController alloc] initWithRootViewController:self.window.rootViewController];
navigationController.navigationBar.tintColor = [UIColor
colorWithRed:217.0/255
green:33.0/255
blue:0
alpha:1];
navigationController.navigationBarHidden = YES;
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
我RootViewController的嘗試另一個視圖 - 控制加載到導航控制器在其viewDidLoad
方法棧但由於某種原因認爲是沒有得到推:
-(void) viewDidLoad{
lvc = [[LoginViewController alloc] init];
//lvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[lvc setDelegate:self];
//[self presentModalViewController:lvc animated:YES];
[self.navigationController pushViewController:lvc animated:YES];
}
我越來越沒有錯誤,所以不知道怎麼回事......使用presentModalViewController
作品...所以真的很困惑!
這也行不通... – user559142
你導入'LoginViewController'?因爲這是你如何推新視圖。 – WrightsCS
是的,我是...它不會編譯,如果我不是... – user559142