i try use uipopoverpresentationcontroller
. presenting need assign delegate (uipopoverpresentationcontrollerdelegate
) able use methods prepareforpopoverpresentation
, popoverpresentationcontrollerdiddismisspopover
, on.
if assign view controller delegate property get
error cs0266 cannot implicitly convert type 'uikit.uiviewcontroller' 'uikit.iuipopoverpresentationcontrollerdelegate'. explicit conversion exists (are missing cast?)
so options here? in native world 1 add required protocoll, can't in xamarin. want view controller presented in popover gets notification (prepare, did dismiss, ...). how can that?
of course create new instance of uipopoverpresentationcontrollerdelegate
, assign it, have connect delegate view controller somehow (e.g. through events). there simpler solution?
edit
it looks xamarin has not exposed weakdelegate
property , has made delegate class abstract class protocol , not interface. in scenario - have create class implements uipopoverpresentationcontrollerdelegate
, uipopovercontrollerdelegate
.
in future, it's worth noting there weakdelegate
property (along delegate
) allows assigning class delegate , implementing protocol implicitly through exportattribute
on protocol methods. xamarin uses protocol's matching interface (such iuipopoverpresentationcontrollerdelegate
) instead of matching abstract class (the uipopoverpresentationcontrollerdelegate
class).
mostly incorrect original answer
it should possible uiviewcontroller
class implement iuipopovercontrollerdelegate
, implement methods need. ios protocols converted interface xamarin.ios , can find appending "i" protocol name.
public class testvc : uiviewcontroller, iuipopovercontrollerdelegate { public override uipopoverpresentationcontroller popoverpresentationcontroller { { return base.popoverpresentationcontroller; } } [export ("popovercontrollerdiddismisspopover:")] public void diddismiss (uipopovercontroller popovercontroller) { throw new notimplementedexception (); } }
here example i've implemented few of popover methods. hope helps. haven't explicitly tested this, think should work. let me know if doesn't.
Comments
Post a Comment