我正在通过PhoneGap插件加载应用程序(通过嵌入式框架)。
现在,我试图将当前的UIViewController传递给FlashizFacade对象的 parentViewController 属性。
当我执行我的应用程序时,在分配自我时,我在调试控制台中收到此错误:


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:decidePolicyForNavigationAction:request:frame:decisionListener:委托:<NSInvalidArgumentException>-[FlashizPlugin navigationController]:无法识别的选择器发送到实例时丢弃了未捕获的异常0x91925e0


分配self.viewController时:



2012-09-10 14:31:21.455 gTicketSales [3693:16a03] *** WebKit丢弃了webView:decidePolicyForNavigationAction:request:frame:decisionListener:委托:<Wrong parentViewController specified>中未捕获的异常使用非模式显示时,必须将parentViewController设置为分配了有效的NavigationController的UIViewController的实例



我试过了:

facade.parentViewController = self;
facade.parentViewController = self.viewController;

我的.h文件
#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

我的.m文件
#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

提前致谢!

最佳答案

在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放在viewDidLoadMainViewController.m
self.navigationController.navigationBar.hidden = YES;

10-08 12:10