2016-08-02 69 views
4

我有一個UIBarButtonItem還沒有被渲染結果和這樣開的酥料餅的一個觀點:UIAlertController popoverPresentationController錯誤:快照,在一個空的快照

@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) 
} 

當我打開酥料餅與功能,我得到這個警告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它只有兩個UIAlertAction s

回答

2

你可以找到answer堆棧溢出類似的問題。 您只需在presentViewController之後調用layoutIfNeeded即可。

presentViewController(alertController, animated: true, completion: nil) 
[alertController.view layoutIfNeeded];