我有一个问题,我的popover正常运行IOS 7.1,但IOS 8.3显示为空。
self.view.endEditing(true);
let timeViewStoryboard : UIStoryboard?;
if UI_USER_INTERFACE_IDIOM() == .Pad {
//IF IPAD
NSLog("PAD");
timeViewStoryboard = UIStoryboard(name: "StoryboardiPad", bundle: nil);
}
else {
//IF IPHONE
timeViewStoryboard = UIStoryboard(name: "Main", bundle: nil);
}
let timePickerViewController : TimePickerViewController = timeViewStoryboard!.instantiateViewControllerWithIdentifier("TimePickerViewController_ID") as! TimePickerViewController;
if UI_USER_INTERFACE_IDIOM() == .Pad {
//Delegating
//timePickerViewController.delegate = self;
if (self.view.window != nil) {
timePickerViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover = UIPopoverController(contentViewController: timePickerViewController);
timePickerViewController.parentPopover = popover;
let height = self.view.frame.height;
let width = self.view.frame.width;
popover.presentPopoverFromRect(CGRectMake(width/2, 44, 1, 1), inView: self.view, permittedArrowDirections: UIPopoverArrowDirection.Up, animated: true);
}
}
这就是我用来显示popover的内容。
这就是iOS 7.1上的样子: http://i.stack.imgur.com/e1paQ.png
这是iOS 8.3上的样子: http://i.stack.imgur.com/ZjppC.png
感谢您提供任何帮助
编辑3:我现在发现它绝对不是我的代码。在故事板按钮直接转换的情况下也没有显示出来。
编辑2:我也尝试过使用另一种创建弹出窗口的方法。
timePickerViewController.modalPresentationStyle = .Popover;
timePickerViewController.preferredContentSize = timePickerViewController.view.frame.size;
let popoverTimePickerViewController = timePickerViewController.popoverPresentationController;
popoverTimePickerViewController?.permittedArrowDirections = .Any;
popoverTimePickerViewController?.delegate = self;
popoverTimePickerViewController?.sourceView = self.view;
let height = self.view.frame.height;
let width = self.view.frame.width;
popoverTimePickerViewController?.sourceRect = CGRectMake(width - 93, 35, 1, 1);
presentViewController(timePickerViewController, animated: true, completion: nil);
但这种方法也不起作用。
但是,我发现popover并没有为UITableViewController而不是UIViewController显示为空。显示UITableViewController的单元格。
编辑:我添加了一些图片以更好地展示我的问题。如果有人需要更多信息以解决我的问题,请询问并且我会愉快地提供尽可能多的信息。谢谢!