ios - 在 PopOverViewController 中显示 UISplitviewController

标签 ios ipad ios4 uisplitviewcontroller

最近,当点击按钮时,我通过弹出窗口中的表格 View 向用户显示项目列表。该表显示了部分和标题。

我现在正在尝试使用不同的方式来显示信息,并且我想尝试在 UISplitViewController 中显示数据。左 View 是一个带有标题的 tableviewcontroller。右侧 View 也是一个带有子标题的 tableviewcontroller。

我仍然希望以弹出窗口的方式提供数据,但是当我尝试这样做时,弹出窗口中什么也没有出现。我已在 SplitView 的左 View 和右 View 的 viewDidLoad 方法中放置了断点。中断被击中,但我的弹出窗口中没有显示任何内容。

如何在 PopoverController 中显示 UISplitView。

我的 Root View

- (IBAction)showPopover:(id)sender {

 self.SVC = [[SplitViewContainerViewController alloc] init];

 self.pickerPopover = [[[UIPopoverController alloc] initWithContentViewController:SVC] autorelease];


CGRect frame= CGRectMake(0,0, 0, 0);
[self.pickerPopover presentPopoverFromRect:frame inView:self.view permittedArrowDirections:0 animated:NO];

SplitViewContainerViewController的LoadView

- (void)loadView
{
    UIView *view=[[[UIView alloc]initWithFrame:CGRectMake(0, 0, 750, 880)]retain];
    self.view=view;
    self.splitViewController = [[UISplitViewController alloc] init];
    self.leftViewController=[[[LeftViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
    self.rightViewController=[[[RightViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];

     self.splitViewController.viewControllers= [NSArray arrayWithObjects:self.leftViewController, self.rightViewController, nil];
    [self.view addSubview:self.splitViewController.view];
    self.contentSizeForViewInPopover = CGSizeMake(750,880);

    [super loadView];

}

最佳答案

UISplitViewController 除非是窗口的 Root View Controller ,否则不起作用。为了执行类似的操作,您需要创建一个自定义 Split View Controller 并使用它而不是 UISplitViewController。

来自Apple's documentation :

A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application's window. The panes of your split-view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface.

您可能想首先查看 MGSplitViewController但是,请注意,iOS 4 及更低版本中存在一些限制,包括无法正确地将旋转以及 View 出现和消失事件传递到 subview Controller 。

关于ios - 在 PopOverViewController 中显示 UISplitviewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8270741/

相关文章:

ios - 根据 UITableView 中的行数调整 UIPopoverController 大小

ios - 以编程方式创建居中的 UIBarButton

ios - 如何将 UIView 移动到 iOS 中的新位置?

ios - iOS 中 Setter 和 Getter 的来龙去脉?

iphone - 如何获取iPhone中安装的应用程序名称列表

iphone - iOS 5.0.1:如何为iCloud验证文件夹是否标记为“不备份”?

ios - 从应用商店更新后应用崩溃。问题可能与核心数据有关?

iphone - 如何向 MPMoviePlayer 添加另一个视频?

ios - 使用 Objective-C 从 url 检索 JSON

objective-c - 对 ARC 下对象的弱引用 (__unsafe_unretained) 的 NSArray