c# - Xamarin iOS - Interactive Swipe -


i trying implement swipe xamarin ios app big names having. found simple example written in swift, stuck second code area.

class myviewcontroller: uiviewcontroller, uinavigationcontrollerdelegate  {      override func awakefromnib() {         super.awakefromnib()         self.navigationcontroller?.delegate = self     }      func navigationcontroller(navigationcontroller: uinavigationcontroller, animationcontrollerforoperation operation: uinavigationcontrolleroperation, fromviewcontroller fromvc: uiviewcontroller, toviewcontroller tovc: uiviewcontroller) -> uiviewcontrolleranimatedtransitioning? {         return simpleanimationcontroller()     } }  

the problem is, in c# class can inherit 1 class or multiple interfaces. don't know function func navigationcontroller doing.

so how can translate code snippet?

thanks help!

[edit 1]

so implemented class this:

public class myfadetransition : uipercentdriveninteractivetransition, iuiviewcontrolleranimatedtransitioning {     private uiviewcontroller transitioningcontroller;      public myfadetransition(uiviewcontroller transitioningcontroller)     {         transitioningcontroller = transitioningcontroller;         transitioningcontroller.view.addgesturerecognizer(new uipangesturerecognizer(didpan));     }      void iuiviewcontrolleranimatedtransitioning.animatetransition(iuiviewcontrollercontexttransitioning transitioncontext)     {         var fromviewcontroller = transitioncontext.getviewcontrollerforkey(uitransitioncontext.fromviewcontrollerkey);          var toviewcontroller = transitioncontext.getviewcontrollerforkey(uitransitioncontext.toviewcontrollerkey);         transitioncontext.containerview.addsubview(toviewcontroller.view);          toviewcontroller.view.alpha = 0.0f;          uiview.animate(0.35, () =>         {             toviewcontroller.view.alpha = 1.0f;             debug.writeline("custom transitioning");          }, () =>         {             transitioncontext.completetransition(!transitioncontext.transitionwascancelled);             debug.writeline("custom transitioning done");          });     }      double iuiviewcontrolleranimatedtransitioning.transitionduration(iuiviewcontrollercontexttransitioning transitioncontext)     {         return 0.35;     }      public void didpan(uipangesturerecognizer gesture)     {         var point = gesture.locationinview(transitioningcontroller.view);         double percent = math.max(math.min((point.x / 300), 0.99), 0.0f);          debug.writeline(string.format("point: {0} | percent: {1}", point, percent));          switch (gesture.state)         {             case uigesturerecognizerstate.began:                 // this.usinggesture = true                 this.transitioningcontroller.navigationcontroller?.popviewcontroller(true);                 break;             case uigesturerecognizerstate.changed:                 updateinteractivetransition((system.nfloat)percent);                 break;             case uigesturerecognizerstate.ended:             case uigesturerecognizerstate.cancelled:                 if (percent > 0.5)                 {                     debug.writeline("finishing transition");                     this.finishinteractivetransition();                 }                 else                 {                     debug.writeline("cancelling transition");                     this.cancelinteractivetransition();                 }                 break;             default:                 debug.writeline("unhandled transition state");                 break;         }     } } 

now viewcontrollers transitioning, if user swipes pixels. idea happening here?

in xamarin.ios have interface equivalent:

iuinavigationcontrollerdelegate 

you can implement many interfaces want.

you can find right here

the xamarin translation be

public class myviewcontroller : uiviewcontroller, iuinavigationcontrollerdelegate {      public override void awakefromnib()     {         base.awakefromnib();         navigationcontroller.delegate = this;     }      [export("navigationcontroller:animationcontrollerforoperation:fromviewcontroller:toviewcontroller:")]     public iuiviewcontrolleranimatedtransitioning getanimationcontrollerforoperation(uinavigationcontroller navigationcontroller, uinavigationcontrolleroperation operation, uiviewcontroller fromviewcontroller, uiviewcontroller toviewcontroller)     {         return new simpleanimationcontroller();     } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -