2***@qq.com
2***@qq.com
  • 发布:2023-10-05 23:07
  • 更新:2023-10-05 23:07
  • 阅读:150

【报Bug】iOS 本地component插件updateAttributes不回调

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 14.0

HBuilderX类型: 正式

HBuilderX版本号: 3.8.12

手机系统: iOS

手机系统版本号: iOS 14

手机厂商: 苹果

手机机型: 13pro

页面类型: nvue

vue版本: vue2

打包方式: 离线

项目创建方式: HBuilderX

示例代码:

js更新属性:

<HMap v-if="mapshow" ref="hmap" style="width: 100%; height: 400rpx;" showcorver:"true" :markers="markcovers" :location="location"></HMap>  

// 无论怎么改变covers或者下面的lat和long数据,都不会触发updateAttributes  
computed: {  
        markcovers() {  
            console.log("computed markcovers")  
            return this.covers  
        },  
        location() {  
            console.log("computed location")  
            return {'latitude':this.latitude, 'longitude':this.longitude, 'zoom':this.scale};  
        }  
}  

OC中注册插件

<key>dcloud_uniplugins</key>  
    <array>  
        <dict>  
            <key>hooksClass</key>  
            <string></string>  
            <key>plugins</key>  
            <array>  
                <dict>  
                    <key>class</key>  
                    <string>HMapComponent</string>  
                    <key>name</key>  
                    <string>HMap</string>  
                    <key>type</key>  
                    <string>component</string>  
                </dict>  
            </array>  
        </dict>  
    </array>  
实现代码:  
@interface HMapComponent : DCUniComponent  
@end  

@interface HMapComponent()<HMapViewDelegate>  
@end  
@implementation HMapComponent  

- (UIView *)loadView {  
    self.mapView = [HMapView new];  
    return self.mapView;  
}  

- (void)onCreateComponentWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events uniInstance:(DCUniSDKInstance *)uniInstance {  
    NSLog(@"onCreateComponentWithRef attributes:%@", attributes);  
}  

- (void)updateStyles:(NSDictionary *)styles {  
    NSLog(@"updateStyles styles:%@", styles);  
}  

/// 前端更新属性回调方法  
/// @param attributes 更新的属性  
- (void)updateAttributes:(NSDictionary *)attributes {  
}  

操作步骤:

如上demo

预期结果:

可以回调

实际结果:

不能回调

bug描述:

求助,看不到源码,各种尝试,干着急。
iOS原生插件开发:

  • (void)updateAttributes:(NSDictionary *)attributes
  • (void)updateStyles:(NSDictionary *)styles
    这两个属性更新方法不回调。

下面的方法可以正常回调:

  • (void)onCreateComponentWithRef:(NSString )ref type:(NSString )type styles:(NSDictionary )styles attributes:(NSDictionary )attributes events:(NSArray )events uniInstance:(DCUniSDKInstance )uniInstance

这个暴露方法js也是可以正常调用。
UNI_EXPORT_METHOD(@selector(xx:))

2023-10-05 23:07 负责人:无 分享
已邀请:

要回复问题请先登录注册