第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

weex 在ios怎么調用.we文件

weex 在ios怎么調用.we文件

冉冉說 2018-10-01 17:12:54
查看完整描述

1 回答

?
拉風的咖菲貓

TA貢獻1995條經驗 獲得超2個贊

 項目初始化1、沒有現(xiàn)成的工程的話新建ios項目命令行cd到項目根目錄 執(zhí)行 pod init,會創(chuàng)建一個pod配置文件用編輯器打開,加上 pod 'WeexSDK', :path=>'./sdk/'

  /weex在ios目錄下有個sdk文件夾,把它復制到ios項目根目錄,和podFile里配置的路徑一致關掉xcode,在當前目錄,命令行執(zhí)行pod install,現(xiàn)在項目目錄變成了這樣,以后點擊xcworkspace文件打開項目創(chuàng)建一個新目錄weex,命令行cd到weex目錄,執(zhí)行weex init,會提示你輸入項目名稱自動創(chuàng)建的文件:

  在當前目錄命令行執(zhí)行npm install,安裝依賴庫創(chuàng)建一個文件夾js,命令行執(zhí)行weex src -o js生成最終需要的js文件也可以weex src/main.we在瀏覽器預覽或者weex src/main.we --qr 生成二維碼,用playground App 掃描預覽加載weex頁面xcode打開workspace項目文件打開AppDelegate.m添加一下內容將之前創(chuàng)建的js文件夾拖到xcode工程的文件列表效果是這樣的weex視圖控制器的初始化ViewController.h:

  [objc] view plain copy在CODE上查看代碼片派生到我的代碼片//// ViewController.h// weexDemo3//// Created by admin on 16/8/3.

  // Copyright ? 2016年 admin. All rights reserved.

  //#import <UIKit/UIKit.h>

  @interface ViewController : UIViewController- (instancetype)initWithJs:(NSString *)filePath;@endViewController.m:

  [objc] view plain copy在CODE上查看代碼片派生到我的代碼片//// ViewController.m// weexDemo3//// Created by admin on 16/8/3.

  // Copyright ? 2016年 admin. All rights reserved.

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

  @interface ViewController ()@property (nonatomic, strong) WXSDKInstance *instance;@property (nonatomic, strong) UIView *weexView;@end@implementation ViewController{NSURL *jsUrl;}

  - (instancetype)initWithJs:(NSString *)filePath{self = [super init];if (self) {//遠程js文件// NSString *path=[NSString stringWithFormat:@"http://192.168.232.13:8080/examples/js/%@",filePath];//本地js文件NSString *path=[NSString stringWithFormat:@"file://%@/js/%@",[NSBundle mainBundle].bundlePath,filePath];NSLog(@"-----path:%@",path);jsUrl=[NSURL URLWithString:path];}

  return self;}

  - (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:weakSelf.weexView];};_instance.onFailed = ^(NSError *error) {NSLog(@"加載錯誤");};_instance.renderFinish = ^ (UIView *view) {NSLog(@"加載完成");};if (!jsUrl) {return;}

  [_instance renderWithURL: jsUrl];self.view.backgroundColor=[UIColor whiteColor];}

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

  }

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

  @end再打開AppDelegate成都軟件開發(fā)公司http://www.yingtaow.com?chidcd創(chuàng)建導航控制器引入頭文件#import "ViewController.h"創(chuàng)建導航視圖:

  [objc] view plain copy在CODE上查看代碼片派生到我的代碼片- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {//weex[self initWeex];ViewController *vc=[[ViewController alloc]initWithJs:@"main.js"];UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:vc];self.window.rootViewController=nav;return YES;}

  運行圖片不顯示是因為圖片加載需要自己創(chuàng)建模塊,可以直接把demo的代碼和pod配置粘過來使用

查看完整回答
反對 回復 2018-10-10
  • 1 回答
  • 0 關注
  • 882 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號