最近,当点击按钮时,我通过弹出窗口中的表格 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。
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/