首页 > 代码库 > UIPopoverPresentationController的使用

UIPopoverPresentationController的使用

UIPopoverPresentationController的使用

by 伍雪颖

let detailsButton: UIBarButtonItem = UIBarButtonItem(title: "PopView", style: UIBarButtonItemStyle.Plain, target: self, action: "displayPopView:")
navigationItem.rightBarButtonItem = detailsButton
   
func displayPopView(sender: UIBarButtonItem) {
    let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    var contentViewController : CountryPopoverViewController = storyboard.instantiateViewControllerWithIdentifier(
        "PopoverViewController")
        as CountryPopoverViewController; contentViewController.country = country
    contentViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
    var detailPopover: UIPopoverPresentationController = contentViewController.popoverPresentationController!
    detailPopover.barButtonItem = sender
    UIPopoverArrowDirection.Any; presentViewController(contentViewController,
        animated: true, completion:nil)
}


UIPopoverPresentationController的使用