weex 自定义Component
~ Component 与UI控件相关 ,即通过原生方法创建UI界面,返回给weex 使用
一. 新建 WXComponent 的子类
在子类实现WXComponent 的生命周期方法
.h
#import "WXComponent.h" @interface MyComponent : WXComponent @end
.m
#import "WXDatePickerComponent.h" //原生自定义的UI控件类
@interface WXDatePickerView : UIDatePicker @end @implementation WXDatePickerView @end
@interface WXDatePickerComponent()
@property (nonatomic, strong) WXDatePickerView *datePickerView;
@property (nonatomic, assign) BOOL changeEvent; @end
//component 的.m
@implementation WXDatePickerComponent
- (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance
{
if (self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]) { }
return self;
}
//返回给weex,原生创建的UI控件
- (UIView *)loadView
{
return [[WXDatePickerView alloc] init];
} - (void)viewDidLoad
{
_datePickerView = (WXDatePickerView *)self.view;
_datePickerView.backgroundColor =[UIColor whiteColor];
[_datePickerView setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"]];
[_datePickerView setTimeZone:[NSTimeZone localTimeZone]];
[_datePickerView setDate:[NSDate date] animated:YES];
[_datePickerView setMaximumDate:[NSDate date]];
[_datePickerView setDatePickerMode:UIDatePickerModeDate];
[_datePickerView addTarget:self action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged]; }
- (void)datePickerValueChanged:(UIDatePicker *)datePicker{
if (_changeEvent) {
[self fireEvent:@"change" params:@{@"value":datePicker.date} domChanges:@{@"attrs": @{@"checked": datePicker.date}}];
}
}
二. 注册
*注意: 自定义的Component的需要在WeexSDK 初始化的时候 注册
[WXSDKEngine registerComponent:@"MyView" withClass:[MyViewComponent class]];
weex 自定义Component的更多相关文章
- Ionic2学习笔记(2):自定义Component
作者:Grey 原文地址: http://www.cnblogs.com/greyzeng/p/5536298.html 上一篇提到,Ionic2提供了很多Co ...
- weex 自定义Modul
扩展iOS的功能 一. 新建 NSOjbect 子类, 并遵循协议<WXModuleProtocol> .h 代码 #import <Foundation/Foundation.h& ...
- #Weex与Android交互(一)
用Weex开发Android程序 参考:开发HelloWorld程序(Weex开发) 1.创建Android工程 2.集成WeexSDK,参考[WEEX SDK 集成到 Android 工程](htt ...
- 第八章 交互技术,8.4 Weex 双11会场大规模应用的秒开实战和稳定性保障(作者:鬼道)
8.4 Weex 双11会场大规模应用的秒开实战和稳定性保障 前言 Native 开发的诸多亮点中,流畅体验和系统调用是最多被提及的.流畅体验体现在页面滚动/动画的流畅性,背后是更好的内存管理和更接近 ...
- salesforce lightning零基础学习(四) 事件(component events)简单介绍
lightning component基于事件驱动模型来处理用户界面的交互.这种事件驱动模型和js的事件驱动模型也很相似,可以简单的理解成四部分: 1.事件源:产生事件的地方,可以是页面中的输入框,按 ...
- 创建自定义的 Angular Schematics
本文对 Angular Schematics 进行了介绍,并创建了一个用于创建自定义 Component 的 Schematics ,然后在 Angular 项目中以它为模板演练了通过 Schemat ...
- Weex与Android交互(二)
扩展Android Weex 提供了扩展机制,可以根据自己的业务进行定制自己的功能. 主要分为两类扩展: Module 扩展 非UI的特定功能.例如sendHttp.openURL 等. Compon ...
- Angular(二) - 组件Component
1. 组件Component示例 2. Component常用的几个选项 3. Component全部的选项 3.1 继承自@Directive装饰器的选项 3.2 @Component自己特有的选项 ...
- 「免费开源」基于Vue和Quasar的前端SPA项目crudapi后台管理系统实战之自定义组件(四)
基于Vue和Quasar的前端SPA项目实战之序列号(四) 回顾 通过上一篇文章 基于Vue和Quasar的前端SPA项目实战之布局菜单(三)的介绍,我们已经完成了布局菜单,本文主要介绍序列号功能的实 ...
随机推荐
- 修改字段类型modify
alter table 表名 modify column 字段名 类型;
- EF配置文件初始化数据库 codefirst
. using ConsoleApplication42; using System.Data.Entity; using System.Data.Entity.ModelConfiguration. ...
- web测试——完结感言
1.在小组所有成员一人找出了博客园的2个小bug. 2.杨瑞丰与李建文完成了用户调研和定量评价. 3.张颖与汪鸿也完成了产品分析和与CSDN的横向比较. 4.胡俊辉一个人总结所有人的问题与结果,进行了 ...
- SpringMVC源码解读 - HandlerMapping - AbstractDetectingUrlHandlerMapping系列初始化
AbstractDetectingUrlHandlerMapping是通过扫描方式注册Handler,收到请求时由AbstractUrlHandlerMapping的getHandlerInterna ...
- JavaEE互联网轻量级框架整合开发(书籍)阅读笔记(9):通过XML装配Bean
一.通过XML装配Bean 装配简易值 装配集合 命名空间装配(暂不测试) 二.测试例子 创建一个用户类:UserBean.java package com.xfwl.spring.assem; /* ...
- DES加密与解密控制台c++代码
#include"stdafx.h" #include<stdio.h> #include<string.h> void main() { //声明变量 c ...
- [Lua快速了解一下]Lua的函数
-recurrsive function fib(n) end ) + fib(n - ) end -closure 示例一 function newCounter() return function ...
- SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)(Finchley版本)
在上一篇文章讲述zuul的时候,已经提到过,使用配置服务来保存各个服务的配置文件.它就是Spring Cloud Config. 一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管 ...
- WC的基本功能实现.(Java)
我的GitHub地址:https://github.com/Yuetao1219/lessons WC 项目要求 wc.exe 是一个常见的工具,它能统计文本文件的字符数.单词数和行数.这个项目要求写 ...
- opencv——(动态)旋转图像
#include "stdafx.h" #include <opencv2\opencv.hpp> #include <opencv\cv.h> #incl ...