#import "QMATestView.h"
#import "TMAExternalJSPlugin.h"
@interface QMATestView () <TMAExternalElementView>
@end
@implementation QMATestView {
UILabel *_textLabel;
UIButton *_clickButton;
id<TMAExternalJSContextProtocol> _context;
}
TMARegisterExternalElement(maTestView);
+ (UIView *)createWithParams:(NSDictionary *)params context:(id<TMAExternalJSContextProtocol>)context {
QMATestView *testView = [[QMATestView alloc] initWithFrame:CGRectZero];
NSDictionary *testViewParams = QQ_Dict_DictValue(params, @"params");
[testView setText:QQ_Dict_StringValue(testViewParams, @"text")];
testView->_context = context;
return testView;
}
- (void)operateWithParams:(NSDictionary *)param context:(id<TMAExternalJSContextProtocol>)context {
NSDictionary *data = QQ_Dict_DictValue(param, @"data");
NSDictionary *params1 = QQ_Dict_DictValue(data, @"params1");
NSInteger age = [QQ_Dict_NumberValue(params1, @"age") integerValue];
NSString *name = QQ_Dict_StringValue(params1, @"name");
qq_weakify(self);
[MAUtils executeOnThread:[NSThread mainThread] block:^{
qq_strongify(self);
if (self) {
self->_textLabel.text = [NSString stringWithFormat:@"name = %@ , age = %ld",name,(long)age];
TMAExternalJSPluginResult *result = [TMAExternalJSPluginResult new];
result.result = @{@"result":@"success"};
[context doCallback:result];
}
}];
}
本页内容是否解决了您的问题?