我有一个 UITableView,有行,当你点击每一行时你会看到详细 View ,我想要这个用于 iPhone, 如果我旋转设备并从列表中选择我的行,我必须查看描述。(我的意思是在左边我必须有我的行,在右边我的详细 View )将设备旋转回垂直并隐藏详细 View .
我使用了 splitViewController,但是我有一个错误,请你检查我的代码并让我知道这里有什么问题吗?
提前致谢!
这是代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
ViewController *view = [[ViewController alloc] initWithNibName:@"ViewController"
bundle:nil];
_nav = [[UINavigationController alloc] initWithRootViewController:view];
//
MattersDetailView *detailVC = [[MattersDetailView alloc] initWithNibName:@"MattersDetailView"
bundle:nil];
_nav = [[UINavigationController alloc] initWithRootViewController:detailVC];
[[UINavigationBar appearance] setBarTintColor:[self colorWithHexString:@"ecd555"] ];
splitViewController =[[UISplitViewController alloc] init];
splitViewController.viewControllers = @[view,detailVC];
self.window.rootViewController = splitViewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
然后将此方法添加到两个 viewController .m 文件中
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return YES;
}
但是我有这个错误
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'UISplitViewController is only supported when running under UIUserInterfaceIdiomPad'
最佳答案
阅读 UISplitViewController 的文档。它只能用于 iPad 应用程序,不能用于 iPhone 应用程序。
您需要删除 Split View Controller 并用其他东西替换它。
关于ios - iPhone 'UISplitViewController is only supported when running under UIUserInterfaceIdiomPad',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22055677/