52yaoer
52yaoer
  • 发布:2024-03-18 15:22
  • 更新:2025-11-28 09:58
  • 阅读:404

uts如何实现Delegate的设置

分类:uts

@protocol SVGAPlayerDelegate <NSObject>

@optional

  • (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player ;

  • (void)svgaPlayer:(SVGAPlayer *)player didAnimatedToFrame:(NSInteger)frame;

  • (void)svgaPlayer:(SVGAPlayer *)player didAnimatedToPercentage:(CGFloat)percentage;

  • (void)svgaPlayerDidAnimatedToFrame:(NSInteger)frame API_DEPRECATED("Use svgaPlayer:didAnimatedToFrame: instead", ios(7.0, API_TO_BE_DEPRECATED));

  • (void)svgaPlayerDidAnimatedToPercentage:(CGFloat)percentage API_DEPRECATED("Use svgaPlayer:didAnimatedToPercentage: instead", ios(7.0, API_TO_BE_DEPRECATED));

@end

我这样写

class ISVGAPlayerDelegate implements SVGAPlayerDelegate {
comp : UTSComponent<SVGAPlayer>
constructor(com : UTSComponent<SVGAPlayer>) {
this.comp = com;
super.init()
}

    svgaPlayerDidFinishedAnimation(_player : SVGAPlayer) : void {  
        // this.comp.__$$emit("onFinished");  
        this.comp.fireEvent("onFinished");  
    }  
}  

NVLoaded() { //原生View已创建
this.$el.delegate = new ISVGAPlayerDelegate(this);
},

这样实现后,并不能实现 svgaPlayerDidFinishedAnimation 事件的监听。
另外,- (void)svgaPlayer:(SVGAPlayer *)player didAnimatedToFrame:(NSInteger)frame;

  • (void)svgaPlayer:(SVGAPlayer *)player didAnimatedToPercentage:(CGFloat)percentage; 这2个如何实现呢?
2024-03-18 15:22 负责人:无 分享
已邀请:
52yaoer

52yaoer (作者)

来个技术回答下啊。。。。

52yaoer

52yaoer (作者)

已解决。。结贴

  • 6***@qq.com

    怎么解决的求回复

    2024-04-23 17:03

1***@qq.com

1***@qq.com - uniappx

我也想知道怎么解决的,求回复

  • 1***@qq.com

    解决了,参考示例代码hello-uts-master中的uts-tencentgeolocation 相关代码。

    截取了部分代码

    @protocol TencentLBSLocationManagerDelegate <NSObject>

    @optional


    /**



    • 当定位发生错误时,会调用代理的此方法



    • @param manager 定位 TencentLBSLocationManager 类

    • @param error 返回的错误,参考 TencentLBSLocationError

      */

      • (void)tencentLBSLocationManager:(TencentLBSLocationManager )manager

        didFailWithError:(NSError
        )error;

        // 实现定位出错的 delegate 方法

        tencentLBSLocationManager(manager: TencentLBSLocationManager, @argumentLabel("didFailWithError") error: NSError) {

        this.locationOptions?.fail(error.localizedDescription)

        }


    2025-11-28 10:53

要回复问题请先登录注册