W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
你既可以在全頁面中使用 Weex,也可以在一個 view 中渲染 Weex。只需要創(chuàng)建一個 Weex 實例并指定好回調(diào)方法,提供一個合法的 URL 就可以了。在 ?onCreate
? 回調(diào)方法中將根 view 添加到你想顯示內(nèi)容的地方,并通過? instance.frame =
? 來設(shè)置它的尺寸和位置。
#import <WeexSDK/WXSDKInstance.h>
- (void)viewDidLoad
{
[super viewDidLoad];
_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:view];
};
_instance.onFailed = ^(NSError *error) {
//process failure, you could open an h5 web page instead or just show the error.
};
_instance.renderFinish = ^ (UIView *view) {
//process renderFinish
};
NSURL *url = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"js"];
[_instance renderWithURL:url options:@{@"bundleUrl":[self.url absoluteString]} data:nil];
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: