1
我使用每個單元格中的按鈕製作tableview,當您按下按鈕時顯示彈出窗口,但問題是使popover居中在tableview上,但是如果您沿着tableView並按下按鈕popover用作指南選擇按鈕,所以popover上升。在接下來的圖片中,您可以看到我想要解釋的內容。TableView上的中心彈出如何?
當你從小區按下按鈕使用的代碼:
func buttonPressed(sender: UIButton){
let buttonTag = sender.tag
let width = self.view.frame.midX + (self.view.frame.midX/2)
let height = info[buttonTag].nota.calculateHeight(width: width, sizeFont: 16.0) + 40
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "NotaTable") as! Popever
vc.modalPresentationStyle = UIModalPresentationStyle.popover
vc.popoverPresentationController?.delegate = self
vc.preferredContentSize = CGSize(width: width, height: height + 115)
vc.width = width
let popover: UIPopoverPresentationController = vc.popoverPresentationController!
popover.delegate = self
popover.sourceView = self.view
popover.sourceRect = CGRect(x: self.view.frame.midX - (width/2), y: self.view.frame.midY - (height/2), width: width, height: height)
popover.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
present(vc, animated: true, completion:nil)
}
那麼,如何讓我的酥料餅的關注中心,無論什麼按鈕按下?
感謝提前!