2

下运行时受支持我有一个UITableView,带有行,当你点击每一行时,你将看到详细视图,我想要这个iPhone, 如果我旋转设备并选择我的(我的意思是在左边,我必须有我的行,并在我的详细信息视图中)将设备旋转回垂直并隐藏细节视图。iPhone'UISplitViewController仅在UIUserInterfaceIdiomPad'

我用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' 

回答

1

阅读UISplitViewController文档。它只能用于iPad应用程序,而不能用于iPhone应用程序。

您需要取消拆分视图控制器,并用别的东西代替它。

+0

谢谢你的回复,你知道我怎么能在iPhone上做到这一点? – user3273254

+0

如何做?请明确点。 – rmaddy

+0

当我以横向模式旋转iPhone时,在iPhone中同时具有表格列表和详细视图 – user3273254

0

我有一个的UITableView,与行,当你点击每个排你会看到详细观点,我想这对于iPhone。

由于屏幕比较小,所以您在iPhone上的行为通常在iPhone上处理方式不同。如前所述,它与iPhone不兼容。

要么到详细视图的过渡反映或者在导航简单尝试或一个不起眼的细节图。

如果它是导航你后。抽屉导航菜单很受欢迎。这是一个可与Storyboard和iOS7配合使用并包含教程的程序。 AppCoda SlideNavMenu

如果它只是一个使用主从模板,很好地复制此功能(假设你使用Xcode5)基于使用cell触控输入,我认为你是创建一个新项目的最好的事情过渡。

希望这会有所帮助。