美文网首页
iOS集成weex踩坑记录

iOS集成weex踩坑记录

作者: 送我迷迭香 | 来源:发表于2021-07-01 14:27 被阅读0次

1.iOS 14系统,图片不显示

解决方法
1.找到WXLayer.m文件,修改

- (void)display{
    {
    if(@available(iOS 14.0, *)) {
    [super display];
    }
    [self.wx_component _willDisplayLayer:self];
    }
}

2.修改WXImageComponent.m文件

将

((UIImageView *)strongSelf.view).image = image;

修改为

strongSelf.view.layer.contents = (__bridge id _Nullable)(image.CGImage);

图片即可显示
image.png
2.新界面无法隐藏导航栏

解决方案: 自定义NavigationHandler 实现WXNavigationProtocol 协议,重写了push方法,push跳转到自定义控制器 FBWXRootViewController

[WXSDKEngine registerHandler:[FBWXNavigationHandlerImpl new] withProtocol:@protocol(WXNavigationProtocol)];
- (id)navigationControllerOfContainer:(UIViewController *)container {
    return container.navigationController;
}

- (void)popViewControllerWithParam:(NSDictionary *)param completion:(WXNavigationResultBlock)block withContainer:(UIViewController *)container {
    BOOL animated = YES;
    id obj = [param objectForKey:@"animated"];
    if (obj) {
        animated = [WXConvert BOOL:obj];
    }
    [container.navigationController popViewControllerAnimated:animated];
}

- (void)pushViewControllerWithParam:(NSDictionary *)param completion:(WXNavigationResultBlock)block withContainer:(UIViewController *)container {
    BOOL animated = YES;
    NSString *obj = [[param objectForKey:@"animated"] lowercaseString];
    if (obj && [obj isEqualToString:@"false"]) {
        animated = NO;
    }
    
    FBWXRootViewController *vc = [[FBWXRootViewController alloc]initWithSourceURL:[NSURL URLWithString:param[@"url"]]];
    vc.hidesBottomBarWhenPushed = YES;
    [container.navigationController pushViewController:vc animated:animated];
}

3.weex storage方法在iOS无法直接调用

解决方案: WXStorageModule 在源码中是私有的 ,方法不对外提供 所以在项目中重写了一套,并且注册了同样的module覆盖weex本身的module,该方法要在registerDefaults 后调用

[WXSDKEngine registerModule:@"storage" withClass:[FBCustomStorageModule class]];

    FBCustomStorageModule *storageModule = [[FBCustomStorageModule alloc]init];
    
    [storageModule setItem:@"accessToken" value:fbAccountInfo.accessToken callback:^(id result) {
        
    }];
    
    NSDictionary *userInfoDict = fbAccountInfo.mj_keyValues;

    [storageModule setItem:@"loginData" value: [NSString convertToJsonData:userInfoDict] callback:^(id result) {
        
    }];

相关文章

  • iOS集成weex踩坑记录

    1.iOS 14系统,图片不显示 解决方法:1.找到WXLayer.m文件,修改 2.修改WXImageCompo...

  • Weex入门踩坑记录

    Weex入门踩坑记录

  • Swift 中的 weex

    weex ios 集成参阅:Weex学习与实践:iOS原理篇 swift集成weex 首先将weexsdk集成到项...

  • weex踩坑记录

    weex版本1.5.3npm版本 6.4.1 请求 调用本地包,文件请求使用nat.js http://natjs...

  • Weex 踩坑记录

    1、运行 npm start ,报错如下:webpack-dev-server: command not foun...

  • iOS集成OpenCV

    iOS项目集成OpenCV及踩过的坑 一、直接下载Framework集成 1.1、下载OpenCV的Framewo...

  • weex踩坑记录(2)

    1、在使用storage客户端存储的时候, 变量不能使用局部变量的形式,也就是下面这种是获取不到的,或者获取到了,...

  • weex踩坑记录(1)

    1、组件会被转为p标签,对于字体的样式直接写在组件上,写在外层div无效。2、背景图片直接...

  • weex踩坑记录(4)

    1、weex中默认的css样式不要写: 2、color属性都写全,不然爆出警告(这个可能跟项目的配置有关)colo...

  • weex踩坑记录(3)

    1、loadmore事件不会在web端触发2、不支持百分比单位3、垂直水平居中: justify-content:...

网友评论

      本文标题:iOS集成weex踩坑记录

      本文链接:https://www.haomeiwen.com/subject/jrmjultx.html