我正在使用通用应用(iPhone和iPad)。我有一个应该打开设置视图的按钮,我有两个单独的XIB文件,一个用于iPad,另一个用于iPhone。我有以下代码:
settingsView* sv=[[settingsView alloc]initWithNibName:@"settingsView" bundle:nil];
settingsView* isv=[[settingsView alloc]initWithNibName:@"settingsView_iPad" bundle:nil];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[self presentModalViewController:sv animated:YES];
NSLog(@"I am an iPhone");
}
if([[UIDevice currentDevice] userInterfaceIdiom]== UIUserInterfaceIdiomPad) {
[self presentModalViewController:isv animated:YES];
NSLog(@"I am an iPad");
}
此代码只显示设备上的黑屏,状态栏位于顶部。我不知道为什么。任何帮助将不胜感激。
此致
Hersh K. Bhargava
答案 0 :(得分:0)
解决此问题的最佳方法是,在Class.xib文件中拖放两个UIViewController。创建两个@property(非原子,保留)ClassAVC和@property(非原子,保留)ClassBVC,建立连接到空UIViewController你只需要删除到class.xib文件,并将NIB名称更改为settingsView和settingsView_ipad nib文件名。然后尝试
[self presentModalViewController:ClassAVC animated:YES];
[self presentModalViewController:ClassBVC animated:YES];
以及
[self.navigationController pushViewController:ClassAVC animated:YES];
[self.navigationController pushViewController:ClassBVC animated:YES];