我已經創建了兩個.xib
文件之一肖像模式和其他的景觀模式,加載不同的廈門國際銀行文件
每個旋轉我要加載相應的.xib
文件,
這裏是我的代碼片段,
ViewAppDelegate.m類
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if ([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortrait | [UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortraitUpsideDown)
{
self.viewController = [[OrientationViewController alloc] initWithNibName:@"PortraitController" bundle:nil];
UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = navigationController;
}
else{
self.viewController = [[OrientationViewController alloc] initWithNibName:@"LandscapeController" bundle:nil];
UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = navigationController;
}
[self.window makeKeyAndVisible];
return YES;
}
ViewController.m類
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
-(void)viewWillLayoutSubviews{
if ([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortrait | [UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortraitUpsideDown)
{
[[NSBundle mainBundle] loadNibNamed:@"PortraitController" owner:self options:nil];
}
else{
[[NSBundle mainBundle] loadNibNamed:@"LandscapeController" owner:self options:nil];
}
}
寫這麼多的代碼我的應用程序後顯示什麼..它只顯示黑屏。
請提出一些解決方案。
什麼發生在viewWillLayoutSubviews中保存在shouldAutorotateToInterfaceOrientation中的代碼? – Balu 2013-03-21 06:26:25
它不顯示黑屏,它加載肖像模式的xib文件,當我將它旋轉到風景時,它不會加載風景的xib文件。 – Krunal 2013-03-21 06:30:41
您是否連接了LandscapeController的文件所有者? – Balu 2013-03-21 06:32:30