属性事件添加
@interface MyView : UIView
/// 提供给JS使用的属性
@property (nonatomic, copy) RCTBubblingEventBlock onChange;
属性暴漏
@interface RCTMyViewManager() <MBMapViewDelegate,MBGpsLocationDelegate,MBReverseGeocodeDelegate,UIAlertViewDelegate>
@end
@implementation RCTMyViewManager
@synthesize bridge = _bridge;
RCT_EXPORT_MODULE()
RCT_EXPORT_VIEW_PROPERTY(onChange,RCTBubblingEventBlock)
属性对应
export default class MyView extends React.Component {
// 与 OC中 RCTViewManager子类中导出的属性对应
static propTypes = { onChange: React.PropTypes.func,
};
js中调用监听方法
onchange(event){
console.log('———————————————————— e'+event.nativeEvent.location);
}
<MyView
ref="theMyView"
style={styles.private}
forbidGesture = {false}
zoomLevel = {10}
onChange = {(event) => this.onchange(event)}
/>
网友评论