当我尝试将事件从Obj-C原生UI组件发送到JS时,有人知道reactTag
为nil
为UIScrollView
的原因吗?对于一个按钮,一切正常。
@implementation RCTTouchablePhotoViewManager
RCT_EXPORT_MODULE();
RCT_EXPORT_VIEW_PROPERTY(onTouchCustom, RCTDirectEventBlock);
- (TappableImageView *)imageView {
if (!_imageView) {
_imageView = [[TappableImageView alloc] initWithFrame:CGRectZero];
_imageView.delegate = self;
_imageView.userInteractionEnabled = YES;
_imageView.contentMode = UIViewContentModeScaleAspectFit;
[self.scrollView addSubview:_imageView];
}
return _imageView;
}
- (UIReactScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIReactScrollView alloc] init];
_scrollView.delegate = self;
_scrollView.minimumZoomScale = 0.2;
_scrollView.maximumZoomScale = 4.0;
}
return _scrollView;
}
- (UIView *)view {
return self.scrollView;
}
...
@end
// UIReactScrollView.h
@interface UIReactScrollView : UIScrollView
@property (nonatomic, copy) RCTDirectEventBlock onTouchCustom;
@end