用swift没搞定,用obc就可以,希望对小菜有帮助,大神无视哈
- (void)startBarcode:(PGMethod*)commands
{
if ( commands ) {
// CallBackid 异步方法的回调id,H5+ 会根据回调ID通知JS层运行结果成功或者失败
NSString* cbId = [commands.arguments objectAtIndex:0];
// 用户的参数会在第二个参数传回,可以按照Array方式传入,
//NSDictionary* pArray = [commands.arguments objectAtIndex:1];
// 如果使用Array方式传递参数
//NSString* pResultString = [pArray description];//[NSString stringWithFormat:@"%@ %@ %@ %@",[pArray objectAtIndex:0], [pArray objectAtIndex:1], [pArray objectAtIndex:2], [pArray objectAtIndex:3]];
// 运行Native代码结果和预期相同,调用回调通知JS层运行成功并返回结果
//PDRPluginResult *result = [PDRPluginResult resultWithStatus:PDRCommandStatusOK messageAsString:pResultString];
// 如果Native代码运行结果和预期不同,需要通过回调通知JS层出现错误,并返回错误提示
//PDRPluginResult *result = [PDRPluginResult resultWithStatus:PDRCommandStatusError messageAsString:@"惨了! 出错了! 咋(wu)整(liao)"];
//NSLog(@"-------->%@",pArray);
//NSData* pa=[self resultWithJSON: pArray];
//[obja print:callback: self toCallback: cid:cbId param:pResultString]
UIStoryboard* myStoryBoard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle: nil];
QRViewController *controller = [myStoryBoard instantiateViewControllerWithIdentifier:@"qrview"];
[controller setcallback:@"qrcode" callback:^( NSString *data) {
// request complete
NSLog(@"callback is out %@",data);
PDRPluginResult *result;
result = [PDRPluginResult resultWithStatus:PDRCommandStatusOK messageAsString:data];
[self toCallback:cbId withReslut:[result toJSONString]];
}];
[self presentViewController:controller animated:YES completion:NULL];
// 通知JS层Native层运行结果
//[self toCallback:cbId withReslut:[result toJSONString]];
}
}
inovance
十分感谢!
开发插件时一直无法跳转到其他ViewController,后面看到官方回答:
………………………………………………………………
DCloud_SDK_骁骑 回复 deqiutseng
插件首先要集成PGPlugin类,
继承方法后可以在插件的方法里通过self.rootViewController获取到当前5+运行的viewcontroller
………………………………………………………………
还是不行,感谢让我找到你这里,用presentViewController就搞定了!
@44
2018-04-02 20:27