【发布时间】:2016-05-13 09:07:43
【问题描述】:
我正在尝试制作一个弹出窗口,该弹出窗口将通过按下按钮呈现。尝试按照我在谷歌中找到的说明进行操作,但我的弹出视图以全屏形式呈现,并且其背景为黑色。 这是我的代码:
class ViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@IBAction func someButtonPressed(sender: UIButton) {
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let popupVC = storyboard.instantiateViewControllerWithIdentifier("hello") as! popupViewController
popupVC.modalPresentationStyle = .Popover
popupVC.preferredContentSize = CGSizeMake(300, 300)
let pVC = popupVC.popoverPresentationController
pVC?.permittedArrowDirections = .Any
pVC?.delegate = self
pVC?.sourceView = sender
pVC?.sourceRect = CGRect(x: 100, y: 100, width: 1, height: 1)
presentViewController(popupVC, animated: true, completion: nil)
}
}
我做错了什么?
【问题讨论】:
-
您可以使用这个 pod:EzPopup (github.com/huynguyencong/EzPopup)
标签: ios swift uiviewcontroller popup