我在react native上有一个模块,并在这个任务的标题中抛出了错误。这是模块的代码,我不知道swift或objective-c,所以我需要你给我解释一下,就像“笨蛋的swift”一样。
#import "CheckoutMercadoPagoModule.h"
#import "AppDelegate.h"
@import MercadoPagoSDK;
@implementation CheckoutMercadoPagoModule
RCT_EXPORT_MODULE()
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
RCT_EXPORT_METHOD(startCheckout:(NSString *)publicKey:(NSString *)prefId:(RCTPromiseResolveBlock)resolve:(RCTPromiseRejectBlock)reject) {
[MercadoPagoContext setPublicKey: publicKey];
[MercadoPagoContext setSiteID:@"MLA"];
UINavigationController *checkoutFlow = [MPFlowBuilder startCheckoutViewController:prefId callback:^(Payment *payment) {
NSDictionary *dictionary = @{@"id": payment._id, @"status": payment.status};
resolve(dictionary);
} callbackCancel:nil];
AppDelegate *share = (AppDelegate *)[UIApplication sharedApplication].delegate;
UINavigationController *nav = (UINavigationController *) share.window.rootViewController;
[nav presentViewController:checkoutFlow animated:YES completion:^{}];
}
@end发布于 2017-06-16 23:49:15
尝试在窗口本身而不是rootviewcontroller上显示
[share.window presentViewController:checkoutFlow animated:YES completion:^{}];}
https://stackoverflow.com/questions/44592760
复制相似问题