objective-c - UIPopover 不显示内部 View

标签 objective-c ios ipad uiview uipopovercontroller

我正在使用一个应该只在内部显示一个 UIView 的弹出窗口。但是,尽管弹出窗口出现了,但它只包含一个空 View (以某种深蓝色着色)。 UIViewController 使用的是其中的“PreferencesController”。

我打开弹出窗口的代码如下:

- (IBAction)showPopup:(id)sender {

if (_preferencesController == nil) {
    self.preferencesController = [[PreferencesController alloc]init];
    self.preferencesControllerPopover = [[UIPopoverController alloc] 
                                initWithContentViewController:_preferencesController];
}
[self.preferencesControllerPopover presentPopoverFromBarButtonItem:sender 
                                permittedArrowDirections:0 animated:YES];
}

除此之外,我只有“preferencesController”,除了 viewDidLoad 和“self.contentSizeForViewInPopover = CGSizeMake(800.0, 800.0);

这是我得到的: Popup

知道为什么它不能正常工作吗?

最佳答案

可能的问题

800.0 宽度对于 Popover 来说太大了,无法处理。


documentation for UIViewController :

(讨论contentSizeForViewInPopover)

This property contains the desired size for the view controller when it is displayed in a popover. By default, the width is set to 320 points and the height is set to 1100 points. You can change these values as needed.

The recommended width for popovers is 320 points. If needed, you can return a width value as large as 600 points, but doing so is not recommended.


可能的解决方案

尝试通过从 UIViewController 调用 presentModalViewController:animated: 以模态方式呈现您的 UIViewController,您希望模态视图 Controller 在其上设置动画。

关于objective-c - UIPopover 不显示内部 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11655722/

相关文章:

ios - Xcode 5.1 在 iPad Air 上构建和运行速度非常慢

iphone - NSDate 查找离今天最近的日期

objective-c - 如何使用 xib 文件正确实现 NSWindowController 子类

objective-c - iOS 应用内购买 : only one payment added to the SKPaymentQueue but a SKPaymentTransactionObserver method is getting called multiple times

ios - 在 IB 中将类分配给 VC 会导致黑屏

iphone - CGContext 中的 alpha 像素数

ios - MPMoviePlayerController 无法打开

iphone - 在 iphone 中选择轻按手势上的图像

objective-c - 如何在 UIWebView 中保存 .webarchive?

ios - 围绕固定点旋转 View - Objective-C