【问题标题】:iPhone 'UISplitViewController is only supported when running under UIUserInterfaceIdiomPad'iPhone 'UISplitViewController 仅在 UIUserInterfaceIdiomPad 下运行时受支持'
【发布时间】:2014-02-26 23:19:21
【问题描述】:

我有一个带有行的 UITableView,当您单击每一行时,您将看到详细信息视图,我想要这个用于 iPhone, 如果我旋转设备并从列表中选择我的行,我必须查看描述。(我的意思是在左边我必须有我的行,在右边我的详细视图)将设备旋转回垂直并隐藏详细视图.

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

【问题讨论】:

    标签: ios objective-c uitableview uisplitviewcontroller landscape


    【解决方案1】:

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

    您需要删除拆分视图控制器并将其替换为其他内容。

    【讨论】:

    • 谢谢你的回复,你知道我在 iPhone 上怎么做吗?
    • 怎么办?具体一点。
    • 当我在横向模式下旋转 iPhone 时,在 iPhone 中同时拥有表格列表和详细视图
    • 您必须创建自己的容器视图控制器来显示两者。
    【解决方案2】:

    我有一个 UITableView,带有行,当您单击每个 时,您将看到 详细视图,我想要这个用于 iPhone。

    您所追求的行为在 iPhone 上的处理方式通常不同,因为屏幕更小。如前所述,它与 iPhone 并不真正兼容。

    过渡到详细视图要么反映了导航的简单尝试,要么反映了简陋的详细视图。

    如果它是您所追求的导航。抽屉式导航菜单很受欢迎。这是一个适用于 Storyboard 和 iOS7 并包含教程的版本。 AppCoda SlideNavMenu

    如果它只是基于使用单元格触摸作为输入的过渡,我认为对您来说最好的事情是使用 Master Detail 模板创建一个新项目(假设您使用的是 Xcode5),该模板很好地复制了此功能。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2012-12-02
      • 2012-09-25
      • 1970-01-01
      • 2019-01-10
      • 1970-01-01
      • 1970-01-01
      • 2019-08-29
      • 2015-12-22
      • 1970-01-01
      相关资源
      最近更新 更多