swift - How to show UITableViewController as a UIPopover ViewController -
i need show pop on tableview controller.
i using following code presenting pop on
func showpopover() {
let secondstoryboard = uistoryboard(name: "second", bundle: nil)
viewobj = secondstoryboard.instantiateviewcontrollerwithidentifier("viewcontroller") as! viewcontroller viewobj.modalpresentationstyle = uimodalpresentationstyle.popover viewobj.preferredcontentsize = cgsizemake(400,500) let popoverpresentationcontroller = viewobj.popoverpresentationcontroller popoverpresentationcontroller?.delegate = self popoverpresentationcontroller?.sourceview = self.view //walletbutton popoverpresentationcontroller?.sourcerect = cgrectmake(0, button.frame.origin.y+100, 0, 0) presentviewcontroller(viewobj, animated: true, completion: nil) }
//mark:- uipopoverpresentationcontrollerdelegate methods... starts
func adaptivepresentationstyleforpresentationcontroller(controller: uipresentationcontroller) -> uimodalpresentationstyle{ return uimodalpresentationstyle.none }
as uiviewcontroller tried load uitableviewcontroller not working. uipopover displayed not displayed tableview.
please suggest me thank in-advance
func showpopover() { let tableviewcontroller = uitableviewcontroller() tableviewcontroller.modalpresentationstyle = uimodalpresentationstyle.popover tableviewcontroller.preferredcontentsize = cgsizemake(200, 250) tableviewcontroller.tableview=fonttable presentviewcontroller(tableviewcontroller, animated: true, completion: nil) let popoverpresentationcontroller = tableviewcontroller.popoverpresentationcontroller popoverpresentationcontroller?.sourceview = sender as! uibutton popoverpresentationcontroller?.sourcerect = cgrectmake(0, 0, sender.frame.size.width, sender.frame.size.height) popoverpresentationcontroller?.delegate=self popoverpresentationcontroller?.permittedarrowdirections=uipopoverarrowdirection.up } func prepareforpopoverpresentation(popoverpresentationcontroller: uipopoverpresentationcontroller) { } func popoverpresentationcontrollerdiddismisspopover(popoverpresentationcontroller: uipopoverpresentationcontroller) { } func popoverpresentationcontrollershoulddismisspopover(popoverpresentationcontroller: uipopoverpresentationcontroller) -> bool { return true }
Comments
Post a Comment