gpt4 book ai didi

Xamarin:使用具有 UICompletion 处理程序的 Notify 方法不可用

转载 作者:行者123 更新时间:2023-12-04 16:38:52 24 4
gpt4 key购买 nike

我有这个静态源分析 Xamarin Studio 中的警告:

API Usage Issue: Use the *Notify method that has a UICompletion Handler completion parameter, the bool will tell you if the operation finished



调用 UIView.Animate(double duration, Action animation, Action completion) 时:
UIView.Animate(duration,
() => Animation(),
() => Completion());

但是,我似乎无法将参数传递给 lambda 表达式。这些选项都不能编译:
  • (bool) => Completion()
  • (finished) => Completion()
  • (bool finished) => Completion()

  • 我怎样才能通过 finished参数到完成 block ?

    最佳答案

    Animate静态方法使用 NSAction方法,更多的是 C# 风格的注解和 AnimateNotify使用 UICompletionHandler方法,ObjC 风格...
    Animate方法只是 helper AnimateNotify 周围的 wrapper :

    所以而不是:

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

    您可以使用:
    UIView.AnimateNotify(30, () => { }, (bool finished) => { });

    结果是一样的....

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

    关于Xamarin:使用具有 UICompletion 处理程序的 Notify 方法不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40241056/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com