swift - Why is the message not showing up? -
i created pop up, nothing showing up, added uiviewcontrollers pop ups. why not working? http://puu.sh/hrel9/75081b2a90.png
class interestviewcontroller: uiviewcontroller, uipopoverpresentationcontrollerdelegate { override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "popoversegue" { let interestviewcontroller = segue.destinationviewcontroller as! uiviewcontroller interestviewcontroller.modalpresentationstyle = uimodalpresentationstyle.popover interestviewcontroller.popoverpresentationcontroller!.delegate = self } } func adaptivepresentationstyleforpresentationcontroller(controller: uipresentationcontroller) -> uimodalpresentationstyle { return uimodalpresentationstyle.none }
i believe don't need segue in case. can use example listed below. shows popover button when press it.
import uikit class viewcontroller: uiviewcontroller, uipopoverpresentationcontrollerdelegate { var mypopover : uipopoverpresentationcontroller? @ibaction func buttonpressed(sender: uibutton) { // can init own view controller here var popoverview = self.storyboard?.instantiateviewcontrollerwithidentifier("interestviewcontroller") as! interestviewcontroller popoverview.preferredcontentsize = cgsize(width: 250, height: 200); var destnav = uinavigationcontroller(rootviewcontroller: popoverview) destnav.modalpresentationstyle = uimodalpresentationstyle.popover self.mypopover = destnav.popoverpresentationcontroller self.mypopover?.delegate = self self.mypopover?.sourceview = self.view var theframe = sender.frame self.mypopover?.sourcerect = theframe destnav.modalpresentationstyle = uimodalpresentationstyle.popover destnav.navigationbarhidden = true self.presentviewcontroller(destnav, animated: true, completion: nil) } func adaptivepresentationstyleforpresentationcontroller(controller: uipresentationcontroller) -> uimodalpresentationstyle { return uimodalpresentationstyle.none } }
Comments
Post a Comment