美文网首页
IOS项目集成Weex (入门)

IOS项目集成Weex (入门)

作者: 曾柏超 | 来源:发表于2018-04-12 07:27 被阅读0次
#import <WeexSDK/WeexSDK.h>
#import <AVFoundation/AVFoundation.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
  
    
    
    //business configuration
    [WXAppConfiguration setAppGroup:@"AliApp"];
    [WXAppConfiguration setAppName:@"WeexDemo"];
    [WXAppConfiguration setAppVersion:@"1.0.0"];
    //init sdk enviroment
    [WXSDKEngine initSDKEnvironment];
    //register custom module and component,optional
//    [WXSDKEngine registerComponent:@"MyView" withClass:[MyViewComponent class]];
//    [WXSDKEngine registerModule:@"event" withClass:[WXEventModule class]];
    //register the implementation of protocol, optional
//    [WXSDKEngine registerHandler:[WXNavigationDefaultImpl new] withProtocol:@protocol(WXNavigationProtocol)];
    //set the log level
    [WXLog setLogLevel: WXLogLevelAll];

    
    
    return YES;
}


//
//  ViewController.m
//  demozz
//
//  Created by 柏超曾 on 2018/4/12.
//  Copyright © 2018年 柏超曾. All rights reserved.
//

#import "ViewController.h"
#import <WeexSDK/WXSDKInstance.h>
@interface ViewController ()

@property (nonatomic, strong) WXSDKInstance * instance;
@property (nonatomic, strong) UIView * weexView;
@property (nonatomic, strong) NSURL * url;

@end

@implementation ViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    // Do any additional setup after loading the view, typically from a nib.
    
    _instance = [[WXSDKInstance alloc] init];
    _instance.viewController = self;
    _instance.frame = self.view.frame;
    
    self.view.backgroundColor = [UIColor whiteColor];
    __weak typeof(self) weakSelf = self;
    
    _instance.onCreate = ^(UIView *view) {
        
        [weakSelf.weexView removeFromSuperview];
        weakSelf.view = view;
        [weakSelf.view addSubview:weakSelf.weexView];
        
    };
    
    _instance.onFailed = ^(NSError *error) {
        //process failure
    };

    _instance.renderFinish = ^ (UIView *view) {
        //process renderFinish
    };
    
    self.url = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"js"];
    [_instance renderWithURL:self.url];
    
}

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

@end

相关文章

  • [个人记录]Weex入坑

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

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

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

  • IOS项目集成Weex (入门)

  • Swift 中的 weex

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

  • weex采坑行

    重拾weex,再次体会体会什么是绝望 原来搞过weex,在原有项目的基础上集成weex项目。一路填坑而行。 现在由...

  • weex优秀案例

    # toutiao -weex > 基于WEEX +Vue2.0仿照今日头条的app项目(android/ios)...

  • Weex iOS集成

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

  • weex集成iOS

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

  • weex多页面支持

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

  • weex总结(iOS集成weex)

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

网友评论

      本文标题:IOS项目集成Weex (入门)

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