我有一个UIBarButtonItem并打开一个像这样的popover:
@IBAction func openAdmin(sender: UIBarButtonItem) {
let alertController = UIAlertController(title: nil, message: "Elige una opción", preferredStyle: .ActionSheet)
// action button initializations... ... ...
alertController.popoverPresentationController?.sourceView = self.view
alertController.popoverPresentationController?.sourceRect = sender
presentViewController(alertController, animated: true, completion: nil)
}
当我打开带有该功能的popover时,我会收到4次警告:
Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
我需要做些什么来解决这个警告?
我用相同的警告读了很多问题,但问题是关于相机或UIImageView所涉及的,但我没有使用相机既不是UIImageView. popover它只有两个UIAlertActions
最佳答案 您可以在堆栈溢出中找到类似问题的
answer.
您所要做的就是在presentViewController之后调用layoutIfNeeded.
presentViewController(alertController, animated: true, completion: nil)
[alertController.view layoutIfNeeded];