【发布时间】:2013-02-24 03:16:28
【问题描述】:
在 xcode 4.6 中启动 iPad Master-Detail 应用程序时,纵向时,有一个可关闭的菜单(横向时它始终打开)。在 iOS 5.0 和 iOS 5.1 中,这个菜单(是弹出框的正确名称?)看起来完全不同,见下文:
有没有办法让 5.0 中的弹出框看起来与 5.1(及更高版本)中的一样?例如。它占据屏幕的整个高度,没有额外的边框/箭头等。所需的行为以绿色突出显示,iOS5.0 以红色突出显示。
编辑:我尝试使用自定义 popoverBackgroundViewClass 并(用于定位)手动显示弹出框:
self.masterPopoverController.popoverBackgroundViewClass = [EBPopoverBackgroundView class];
[self.masterPopoverController setPopoverContentSize:CGSizeMake(320, 1004)];
[self.masterPopoverController presentPopoverFromRect:CGRectMake(-20, -40, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
但它只起作用了一点:
弹出框的左侧和底部有我无法删除的斑点(我尝试过特大的弹出框,但底部空间并没有消失。我尝试将其移动到更多离开了,但左边的空间并没有消失)。此外,导航栏太薄了(大约薄了 10 像素),我也无法改变它(尽管最后一点我没有那么努力)。最后但并非最不重要的是,弹出框右侧有一条 1px 的黑线(即使我将 insets 设置为 0)。
我已经实现了这样的背景类:
@interface EBPopoverBackgroundView : UIPopoverBackgroundView
@end
和.m
@implementation EBPopoverBackgroundView {
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
NSLog(@"Init with frame %@", NSStringFromCGRect(frame));
}
return self;
}
- (CGFloat)arrowOffset {
return 0.0;
}
- (void)setArrowOffset:(CGFloat)arrowOffset {
// pass
}
- (UIPopoverArrowDirection)arrowDirection {
return UIPopoverArrowDirectionRight;
}
- (void)setArrowDirection:(UIPopoverArrowDirection)arrowDirection {
// pass
}
+ (CGFloat)arrowHeight {
return 1.0;
}
+ (CGFloat)arrowBase {
return 1.0;
}
+ (UIEdgeInsets)contentViewInsets {
return UIEdgeInsetsMake(0, 0, 0, 0);
}
- (void)drawRect:(CGRect)rect {
NSLog(@"DrawRect %@", NSStringFromCGRect(rect));
[super drawRect:rect];
}
+ (BOOL)wantsDefaultContentAppearance {
return YES;
}
@end
【问题讨论】:
-
你可以使用那个苹果doc,你会在 ios 5、5.1、6 上拥有同样的效果
-
Apple 改变了 UISplitViewController 的工作方式——我不知道有任何兼容性控制。 Apple 的回答大概是将任何运行 5.0 的设备升级到 5.1。
-
你能说得更具体些吗?文档的哪一部分描述了如何解决我的问题?
标签: xcode ipad ios5 uipopovercontroller