Xamarin: Using Notify method that has a UICompletion handler is not available

I have this static warning analysis source in Xamarin Studio:

API usage error: use the * Notify method, which has a parameter UICompletion Handler completion, boolwill tell you if the operation has completed

when calling UIView.Animate(double duration, Action animation, Action completion):

UIView.Animate(duration,
   () => Animation(),
   () => Completion());

However, I cannot pass parameters to the lambda expression. None of these options compile:

  • (bool) => Completion()
  • (finished) => Completion()
  • (bool finished) => Completion()

How to pass this parameter finishedto the completion block?

+4
source share
2 answers

Animate NSAction, # AnimateNotify UICompletionHandler, ObjC...

Animate AnimateNotify:

, :

UIView.Animate(30, () => { }, () => { });

:

UIView.AnimateNotify(30, () => { }, (bool finished) => { });

....

: https://github.com/xamarin/xamarin-macios/blob/fc55e4306f79491fd269ca2495c6a859799cb1c6/src/UIKit/UIView.cs#L121

+8

, AnimateNotify AnimateNotifyAsync, UICompletionHandler bool:

UIView.AnimateNotify(10, () => { }, finished => { });

await UIView.AnimateNotifyAsync(10, () => { }, finished => { });
+2

Source: https://habr.com/ru/post/1658826/


All Articles