2016-03-07 43 views
1

這是我使用至今酥料餅:主辦酥料餅的控制器出現在錯誤的地點

func presentPopoverController(controller: UIViewController, fromView view: UIView) { 

    controller.modalPresentationStyle = UIModalPresentationStyle.Popover 
    controller.preferredContentSize = CGSizeMake(400, 400) 

    let popover = controller.popoverPresentationController 

    popover?.permittedArrowDirections = .Any 

    print(view.frame) 

    popover?.sourceView = view 
    popover?.sourceRect = view.frame //*** 

    presentViewController(controller, animated: true, completion: nil) 
} 

這是它的外觀在屏幕上:

enter image description here

而且這是在控制檯輸出:

(326.0,15.0,63.0,10.0)

如果我刪除與***行那麼它看起來像下面,並且仍然在錯誤的地方:在控制檯上

enter image description here

輸出同上。

回答

0

應該有popover?.sourceRect = view.bounds而不是view.frame