美文网首页
weex总结(iOS集成weex)

weex总结(iOS集成weex)

作者: 拥抱月亮的大星星 | 来源:发表于2018-05-06 21:20 被阅读186次

1.<image>标签使用本地图片

在 iOS 中,Weex 会在 bundle resources 【根目录建个resources文件夹,放入本地图片】中查找。例如,
image 组件的 src 属性为 local:///app_icon', Weex 会加载
 bundle resouce 中名为 app_icon 的图像资源,而字体文件也
以相同的方式工作。

2.<image> src 网络图片不显示问题

//初始化weex
[WXSDKEngine initSDKEnvironment];

//下载图片(自己实现这个协议则可显示下载图片,weex已实现)
[WXSDKEngine registerHandler:[WXImgLoaderDefaultImpl new] withProtocol:@protocol(WXImgLoaderProtocol)];

3.weex 调用 oc

比如 weex要调用oc里面的某个方法或者跳转到某个界面

扩展 iOS 的功能

4.已有项目扩展weex功能

1.跳转跳转界面(如WTestViewController.h)


#import <UIKit/UIKit.h>

@interface WTestViewController : UIViewController
@property (nonatomic, strong) NSString *url;
@end



#import "WTestViewController.h"
#import <WeexSDK/WXSDKInstance.h>




@interface WTestViewController ()
@property (nonatomic, strong) WXSDKInstance *instance;
@property (nonatomic, strong) UIView *weexView;
@end

@implementation WTestViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    _instance = [[WXSDKInstance alloc] init];
    _instance.viewController = self;
    _instance.frame = self.view.frame;
    
    __weak typeof(self) weakSelf = self;
    _instance.onCreate = ^(UIView *view) {
        [weakSelf.weexView removeFromSuperview];
        weakSelf.weexView = view;
        [weakSelf.view addSubview:weakSelf.weexView];
    };
    
    _instance.onFailed = ^(NSError *error) {
        //process failure
    };
    
    _instance.renderFinish = ^ (UIView *view) {
        //process renderFinish
    };
    
//    
    
    
    
    [_instance renderWithURL:[NSURL URLWithString:self.url] options:@{@"bundleUrl":self.url} data:nil];
    //    [_instance renderWithURL:[NSURL URLWithString:@"http://10.83.4.85/weexNative-h5/index.js"] options:nil data:nil];
    
//    NSURL *url = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"js"];
//    [_instance renderWithURL:url options:@{@"bundleUrl":[self.url absoluteString]} data:nil];
}

- (void)dealloc
{
    [_instance destroyInstance];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

2.在根目录添加bundlejs目录,里面存放生成好的js

../bundlejs/index.js

疑问待解决

1.步骤4中是本地js,实际项目是否是把生成的index.js文件放在服务器上?

2.在原生界面不同的地方,如果调不同的weex界面

3.导航条一般怎么处理

4.待续...

相关文章

  • Swift 中的 weex

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

  • [个人记录]Weex入坑

    Weex入门 官方文档 文档iOS集成 开发环境配置 安装node 安装weex开发工具 验证 weex-tool...

  • weex总结(iOS集成weex)

    1.标签使用本地图片 2. src 网络图片不显示问题 3.weex 调用 oc 比如...

  • iOS集成Weex最全面的基础集成(OC)

    iOS 集成Weex入门教程 前言 自Weex发布伊始, 其口号 "Write Once, Run Everywh...

  • weex多页面支持

    在iOS集成weexsdk里面,我们再不同的地方跳转不同的weex界面,则需要不同的index.js weex c...

  • weex_ 安居客项目实战视频教程

    weex视频教程 weex_教程,weex_Android,weex_iOS,weex 第一季 百度网盘地址:ht...

  • weex_项目实战视频教程

    weex视频教程 weex_教程,weex_Android,weex_iOS,weex 第一季 百度网盘地址:ht...

  • Weex iOS集成

    背景 Weex是什么?提出这个问题之前我们先看看weex不是什么,根据文章: 对无线电商动态化方案的思考(三) ·...

  • weex集成iOS

    前言 由于项目的需要,最近接触了一下weex开发,本人刚入门不久,由于weex官方文档的坑太多.....这里主要介...

  • WEEX快速入门

    weex ios 集成WEEX 是阿里推送的一款基于Node.js,轻量级的移动端跨平台动态性技术解决方案,用于构...

网友评论

      本文标题:weex总结(iOS集成weex)

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