【发布时间】:2015-05-18 15:51:56
【问题描述】:
我是 swift 新手,并试图了解如何使用 UIPopoverPresentationController。
我在我的应用程序中需要的是,当按下按钮时,屏幕按钮上的弹出窗口将在屏幕的一半上显示 xib 文件。 现在发生的事情是我设法继续使用第二个视图控制器,但不知道如何加载 xib 文件以及如何使弹出框成为按钮屏幕的一半。这是我的代码
import UIKit
class BaseViewController: UIViewController , UIPopoverPresentationControllerDelegate {
@IBAction func moveToPopoverView(sender: UIButton) {
var popoverViewController = self.storyboard?.instantiateViewControllerWithIdentifier("Popover") as! UIViewController
popoverViewController.modalPresentationStyle = .Popover
popoverViewController.preferredContentSize = CGSizeMake(200, 200)
let popoverPresentationViewController = popoverViewController.popoverPresentationController
popoverPresentationViewController?.permittedArrowDirections = .Any
popoverPresentationViewController?.delegate = self
presentViewController(popoverViewController, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
}
}
【问题讨论】:
标签: xcode swift ios8 uipresentationcontroller