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项目实战之布局菜单(三)的介绍,我们已经完成了布局菜单,本文主要介绍序列号功能的实 ...
随机推荐
- (转)Android SDK Manager国内无法更新的解决方案
转载地址:http://www.linuxidc.com/Linux/2015-01/111958.htm 现在由于GWF,google基本和咱们说咱见了,就给现在在做Android 或者想学习An ...
- jquery的get()方法
通过检索匹配jQuery对象得到对应的DOM元素. .get( [index ] ) index 类型: Integer 从0开始计数,用来确定获取哪个元素. .get() 方法允许我们直接访问jQu ...
- OpenGL坐标变换专题
OpenGL坐标变换专题(转) OpenGL通过相机模拟.可以实现计算机图形学中最基本的三维变换,即几何变换.投影变换.裁剪变换.视口变换等,同时,OpenGL还实现了矩阵堆栈等.理解掌握了有关坐 ...
- p2093 [国家集训队]JZPFAR
传送门 分析 首先给大家推荐一个非常好的KDTree笔记 here 此题就是y9ong优先队列维护距离最远的k个,最后输出队首元素即可 估价函数就是max和min两点到 询问点的最远距离 代码 #in ...
- windows cmd命令相关知识和经验的碎片化记录
1.循环遍历当前文件夹下的所有*.dll文件,并打印其绝对路径和相对路径 ``` for /f "tokens=*" %%a in ('dir /s/b/a-d "*.d ...
- twitter集成第三方登录是窗口一直出现闪退的解决方法
需要创建自己的token,如下图
- [GO]结构体指针变量初始化
package main import "fmt" func main() { type student struct { id int name string sex byte ...
- java之常用的依赖文件pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...
- C# 加密(Encrypt) 解密(Decrypt) 操作类 java与 C# 可以相互加密解密
public sealed class EncryptUtils { #region Base64加密解密 /// <summary> /// Base64加密 /// </summ ...
- scalaWindows和Linux搭建
Windows搭建 https://www.cnblogs.com/freeweb/p/5623372.html Linux搭建 https://www.cnblogs.com/freeweb/p/5 ...