内置MGSplitViewController的弹出窗口 - 方向问题

时间:2014-02-13 12:54:11

标签: ios objective-c ios7 uisplitviewcontroller ipad

我正在寻找一种如何在PopoverController中获取SplitViewController的方法。 (Popover with Splitview inside

现在我使用MGSplitViewController完成了这项工作,但我有,e布局问题取决于方向。

1。当我设置

showsMasterInPortrait = YES;

看起来像这样:http://i.stack.imgur.com/Bd31R.png

2. 当我设置

showsMasterInLandscape = YES;

看起来像这样:http://i.stack.imgur.com/oWCSp.png

我的目标是使用Master |的SplitView细节部分(如案例1),其中细节将其内容拉伸到与popover-controller宽度相同的宽度。

这是我的代码:

MGSplitViewController *customSplitVC = [[MGSplitViewController alloc] init];

customSplitVC.showsMasterInPortrait = YES;
customSplitVC.view.backgroundColor = [UIColor whiteColor];
[customSplitVC setSplitPosition:400 animated:YES];

DetailViewController *detailViewController = (DetailViewController*)[storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
detailViewController.title = @"Detail";

ListViewController *listViewController = [[ListViewController alloc] initWithDetailViewController:detailViewController];
listViewController.title = @"Master";
listViewController.content = self.myContent;

UINavigationController *detaillNC = [[UINavigationController alloc] initWithRootViewController:detailViewController];

listViewController.detailViewController = detailViewController;

UINavigationController *masterNC = [[UINavigationController alloc] initWithRootViewController:listViewController];
customSplitVC.viewControllers = [NSArray arrayWithObjects:masterNC, detaillNC, nil];
customSplitVC.delegate = detailViewController;

UINavigationController *customSplitNC = [[UINavigationController alloc] initWithRootViewController:customSplitVC];

UIBarButtonItem *btnCancel = [[UIBarButtonItem alloc] initWithTitle:@"X" style:UIBarButtonItemStyleDone target:self action:@selector(dismissPopover)];
customSplitVC.navigationItem.rightBarButtonItem = btnCancel;

self.popover = [[UIPopoverController alloc] initWithContentViewController:customSplitNC];
self.popover.delegate = self;
self.popover.popoverContentSize = CGSizeMake(1000, 500);

CGRect rect = CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/2, 1, 1);

[self.popover presentPopoverFromRect:rect inView:self.view permittedArrowDirections:0 animated:NO];

感谢您的帮助

2 个答案:

答案 0 :(得分:0)

试试这个:UINavigationController issue in the master view (iOS 6)

我发现最简单的方法是将以下内容添加到MGSplitViewController.m结尾 - (void)setup

self.view.autoresizesSubviews = NO;

答案 1 :(得分:0)

确保MGSplitViewController实例已添加为rootViewController的{​​{1}}。