我正在通过PhoneGap插件加载一个应用程序(通过嵌入式框架)
现在,我正在尝试将当前的UIViewController传递给 FlashizFacade 对象的 parentViewController 属性。
当我执行我的应用程序时,在分配 self 时,我在调试控制台中收到此错误:
2012-09-10 13:01:43.663 gTicketSales [2805:16a03] - [FlashizPlugin navigationController]:无法识别的选择器发送到实例0x91925e0
2012-09-10 13:01:43.665 gTicketSales [2805:16a03] *** WebKit在webView中丢弃了一个未捕获的异常:decisionPolicyForNavigationAction:request:frame:decisionListener:delegate:
<NSInvalidArgumentException>
- [FlashizPlugin navigationController ]:无法识别的选择器发送到实例0x91925e0
分配 self.viewController 时:
2012-09-10 14:31:21.455 gTicketSales [3693:16a03] *** WebKit在webView中丢弃了一个未捕获的异常:decisionPolicyForNavigationAction:request:frame:decisionListener:delegate:
<Wrong parentViewController specified>
当使用非模态显示,parentViewController必须是UIViewController的实例,并且已分配有效的navigationController
我试过了:
facade.parentViewController = self;
facade.parentViewController = self.viewController;
#import <Cordova/CDVPlugin.h>
#import <FlashizPaymentLib/FlashizFacade.h>
@interface FlashizPlugin : CDVPlugin <FlashizPaymentDelegate> {}
@property (nonatomic, retain) FlashizFacade* flashizFacade;
- (void) openFlashiz:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
@end
#import "FlashizPlugin.h"
@implementation FlashizPlugin
@synthesize flashizFacade;
- (void) openFlashiz:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
NSLog(@"Flashiz Payment Opening...");
NSString *callbackId = [arguments pop];
NSString *invoiceId = [arguments objectAtIndex:0];
FlashizFacade* facade = [[FlashizFacade alloc] initWithEnvironment:FE_TEST];
facade.parentViewController = self;
facade.delegate = self;
self.flashizFacade = facade;
[facade executePaymentForInvoiceId:invoiceId];
[facade release];
CDVPluginResult *result;
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Flashiz Payment Executed..."];
[self writeJavascript:[result toSuccessCallbackString:callbackId]];
}
@end
提前致谢!
答案 0 :(得分:3)
在AppDelegate.h上
@property (nonatomic, strong) UINavigationController *navigationController;
AppDelegate.m上的在application didFinishLaunchingWithOptions
self.window.rootViewController = self.viewController;
这个
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.navigationController = aNavigationController;
self.window.rootViewController = self.navigationController;
在我的项目崩溃,因为我没有ConnectionViewController
,我认为我没有正确包含框架,因为我不知道如何处理Resources文件夹,但我认为它应该适合你。
编辑:我刚刚包含了资源文件夹,它正在运行!!!
如果您不希望phonegap的视图控制器上的navigationBar放入viewDidLoad
MainViewController.m
self.navigationController.navigationBar.hidden = YES;