How to use Storyboard to make popover that can be used in code?

后端 未结 5 2028
小鲜肉
小鲜肉 2020-12-24 03:56

I\'m building a collection of forms each of which contains several fields. Some of the fields are UITextFields that will display a date. I\'ve created a new cla

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 04:35

    Just used the answer from Jonnywho for my SWIFT project. In case you need it:

    Here's the SWIFT version:

        let anchor: UIView = sender
        var viewControllerForPopover = self.storyboard?.instantiateViewControllerWithIdentifier("GameAboutViewController") as! UIViewController?
    
    
        let popover = UIPopoverController(contentViewController: viewControllerForPopover!)
        popover.presentPopoverFromRect(anchor.frame, inView: anchor, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)
    

提交回复
热议问题