i trying modify width of popover, uitableviewcontroller
, takes half of width of parent view. popover called programmatically when button in uitableview
(the parent view) tapped. tried setting preferredcontentsize
of popover , setting sourcerect
popover still takes on entire screen.
class mytableviewcontroller: uitableviewcontroller, uicollectionviewdatasource, uicollectionviewdelegate, uidynamicanimatordelegate, uigesturerecognizerdelegate, cllocationmanagerdelegate, uipopoverpresentationcontrollerdelegate, uiadaptivepresentationcontrollerdelegate { ... func gotoplaces(button: uibutton) { let fromrect = cgrectmake(50.0, 50.0, self.view.bounds.width / 2.0, self.view.bounds.height) let popovervc = storyboard?.instantiateviewcontrollerwithidentifier("otherplaces") popovervc?.modalpresentationstyle = .overfullscreen presentviewcontroller(popovervc!, animated: true, completion: nil) popovervc?.view.backgroundcolor = uicolor.blackcolor().colorwithalphacomponent(0.6) popovervc?.preferredcontentsize = cgsizemake(self.view.bounds.width / 2.0, self.view.bounds.height) let popovercontroller = popovervc?.popoverpresentationcontroller popoverpresentationcontroller?.sourceview = self.view popoverpresentationcontroller?.sourcerect = fromrect popovercontroller?.permittedarrowdirections = .any popovercontroller?.delegate = self } func adaptivepresentationstyleforpresentationcontroller(controller: uipresentationcontroller) -> uimodalpresentationstyle { return .none }
edit: when print of popoverpresentationcontroller?.sourceview
, popoverpresentationcontroller?.sourcerect
they both return nil reason
you asking
popovervc?.modalpresentationstyle = .overfullscreen
so covering whole screen. try using:
popovervc?.modalpresentationstyle = .popover
the
presentviewcontroller(popovervc!, animated: true, completion: nil)
should last delegate can calls wants respond. (i think -- might not matter if uikit delaying presentation.)
Comments
Post a Comment