我有popover的问题。我做的是:
注意: masterViewController =在splitViewController左侧查看 detailViewController =在splitViewController右侧的视图
在旋转结束时,masterViewController向下移动,现在导航和放大之间有空白。的viewController。 (对于图片:http://www.flickr.com/photos/vriel/5470798582/)。当我在旋转之前销毁弹出窗口时(通过点击外部弹出窗口),这个问题不存在。
在我的detailViewController中,我有以下代码:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (popover && popover.popoverVisible) [popover dismissPopoverAnimated:YES];}
-(void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
UIBarButtonItem* button = [UIBarButtonItem allocinitWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showPopover:)];
}
-(void)splitViewController: (UISplitViewController*)svc willShowViewController: (UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
if (self.navigationItem) [self.navigationItem setLeftBarButtonItem:nil animated:NO];
}
-(void)showPopover:(id)sender {
UINavigationController* c = (UINavigationController*)[self getApplicationDelegateObject:@selector(masterViewController)];
if (c) {
if (!popover) {
popover = [UIPopoverController allocinitWithContentViewController:c];
} else {
popover.contentViewController = c;
}
if (popover) {
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
}
}
答案 0 :(得分:0)
终于找到了问题所在
<强>先前:强> 在我创建自己的条形按钮项目以处理旋转之前。事实上,我不应该担心弹出因为苹果已经照顾它了
-(void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
UIBarButtonItem* button = [UIBarButtonItem allocinitWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showPopover:)];
}
更正:
-(void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
if (self.navigationItem) [self.navigationItem setLeftBarButtonItem:barButtonItem animated:NO];
}