weex總結(jié)(iOS集成weex)

1.<image>標(biāo)簽使用本地圖片

在 iOS 中,Weex 會在 bundle resources 【根目錄建個resources文件夾,放入本地圖片】中查找。例如,
image 組件的 src 屬性為 local:///app_icon', Weex 會加載
 bundle resouce 中名為 app_icon 的圖像資源,而字體文件也
以相同的方式工作。

2.<image> src 網(wǎng)絡(luò)圖片不顯示問題

//初始化weex
[WXSDKEngine initSDKEnvironment];

//下載圖片(自己實現(xiàn)這個協(xié)議則可顯示下載圖片,weex已實現(xiàn))
[WXSDKEngine registerHandler:[WXImgLoaderDefaultImpl new] withProtocol:@protocol(WXImgLoaderProtocol)];

3.weex 調(diào)用 oc

比如 weex要調(diào)用oc里面的某個方法或者跳轉(zhuǎn)到某個界面

擴展 iOS 的功能

4.已有項目擴展weex功能

1.跳轉(zhuǎn)跳轉(zhuǎn)界面(如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文件放在服務(wù)器上?

2.在原生界面不同的地方,如果調(diào)不同的weex界面

3.導(dǎo)航條一般怎么處理

4.待續(xù)...

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容