我想在视图控制器中显示视图控制器。我使用popup segue来做到这一点。第二个视图控制器设置如下所示,但无论如何它都以全屏显示。
func tappedView3() {
// get a reference to the view controller for the popover
let popController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "popoverId")
// set the presentation style
popController.modalPresentationStyle = UIModalPresentationStyle.popover
// set up the popover presentation controller
popController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up
popController.popoverPresentationController?.delegate = self
popController.popoverPresentationController?.sourceView = m_tumgun // button
popController.popoverPresentationController?.sourceRect = m_tumgun.bounds
// present the popover
self.present(popController, animated: true, completion: nil)
}
// UIPopoverPresentationControllerDelegate method
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
// Force popover style
return UIModalPresentationStyle.none
}
答案 0 :(得分:0)
您应该使用容器视图。
答案 1 :(得分:0)
class TablePopupController: UIViewController {
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.modalPresentationStyle = .overCurrentContext
self.modalTransitionStyle = .crossDissolve
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
/// to touch button which pressed
///
/// - Parameter sender: button presse
@IBAction func toDismissView(_ sender: AnyObject) {
self.handler!(nil)
self.dismiss(animated: true, completion: nil)
}
您可以通过以下行
在其他控制器中使用它let lifeStyleTablePopup = TablePopupController(nibName: NibName.TablePopupController.rawValue, bundle: nil)
self.present(self.lifeStyleTablePopup, animated: true, completion: {
})
我希望这会对你有所帮助