_instance = [[WXSDKInstance alloc] init];
_instance.frame = CGRectMake(0.0f, YH_NAVIGATIONBAR_HEIGHT, self.view.bounds.size.width, self.view.bounds.size.height - YH_NAVIGATIONBAR_HEIGHT);
_instance.pageObject = self;
_instance.pageName = sourceURL.absoluteString;
_instance.viewController = self;
NSString *newURL = nil;
if ([sourceURL.absoluteString rangeOfString:@"?"].location != NSNotFound) {
newURL = [NSString stringWithFormat:@"%@&random=%d", sourceURL.absoluteString, arc4random()];
} else {
newURL = [NSString stringWithFormat:@"%@?random=%d", sourceURL.absoluteString, arc4random()];
}
NSMutableDictionary *dictConfig = [NSMutableDictionary dictionaryWithDictionary:[YHWeexManager commmonConfigInfo]];
[dictConfig setObject:sourceURL.absoluteString forKey:@"bundleUrl"];
if (self.param) {
[self.param enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
[dictConfig setObject:obj forKey:key];
}];
}
// weex.config.qrCode 关键在这
[_instance renderWithURL:[NSURL URLWithString:newURL] options:dictConfig data:nil];
__weak typeof(self) weakSelf = self;
_instance.onCreate = ^(UIView *view) {
[weakSelf.weexView removeFromSuperview];
weakSelf.weexView = view;
[weakSelf.view insertSubview:view atIndex:0];
};
_instance.onFailed = ^(NSError *error) {
};
_instance.renderFinish = ^(UIView *view) {
[weakSelf _updateInstanceState:WeexInstanceAppear];
};_instance = [[WXSDKInstance alloc] init];
_instance.frame = CGRectMake(0.0f, YH_NAVIGATIONBAR_HEIGHT, self.view.bounds.size.width, self.view.bounds.size.height - YH_NAVIGATIONBAR_HEIGHT);
_instance.pageObject = self;
_instance.pageName = sourceURL.absoluteString;
_instance.viewController = self;
NSString *newURL = nil;
if ([sourceURL.absoluteString rangeOfString:@"?"].location != NSNotFound) {
newURL = [NSString stringWithFormat:@"%@&random=%d", sourceURL.absoluteString, arc4random()];
} else {
newURL = [NSString stringWithFormat:@"%@?random=%d", sourceURL.absoluteString, arc4random()];
}
NSMutableDictionary *dictConfig = [NSMutableDictionary dictionaryWithDictionary:[YHWeexManager commmonConfigInfo]];
[dictConfig setObject:sourceURL.absoluteString forKey:@"bundleUrl"];
if (self.param) {
[self.param enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
[dictConfig setObject:obj forKey:key];
}];
}
// weex.config.qrCode
[_instance renderWithURL:[NSURL URLWithString:newURL] options:dictConfig data:nil];
__weak typeof(self) weakSelf = self;
_instance.onCreate = ^(UIView *view) {
[weakSelf.weexView removeFromSuperview];
weakSelf.weexView = view;
[weakSelf.view insertSubview:view atIndex:0];
};
_instance.onFailed = ^(NSError *error) {
};
_instance.renderFinish = ^(UIView *view) {
[weakSelf _updateInstanceState:WeexInstanceAppear];
};
网友评论