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)到某個界面
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ù)...