gpt4 book ai didi

ios - 将 cordova 添加到我现有的 ios 项目 : cordovaSettingForKey:]: unrecognized selector sent to instance 时出现问题

转载 作者:可可西里 更新时间:2023-11-01 04:28:39 40 4
gpt4 key购买 nike

我试图将 cordova 项目添加到我现有的 ios 项目中。我可以成功编译应用程序。但是当我运行它时,我得到了 cordovaSettingForKey 的异常。

-[__NSDictionaryM cordovaSettingForKey:]: 无法识别的选择器发送到实例 0x147052a30

异常抛出:-[__NSDictionaryM cordovaSettingForKey:]:发送到实例 0x147052a30 的无法识别的选择器

谁知道如何解决这个问题

这是头文件

#import <Cordova/CDVViewController.h>
#import <Cordova/CDVCommandDelegateImpl.h>
#import <Cordova/CDVCommandQueue.h>

@interface MainViewController : CDVViewController

@end

@interface MainCommandDelegate : CDVCommandDelegateImpl
@end

@interface MainCommandQueue : CDVCommandQueue
@end

这是.m文件

#import "MainViewController.h"

@implementation MainViewController

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Uncomment to override the CDVCommandDelegateImpl used
// _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
// Uncomment to override the CDVCommandQueue used
// _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
}
return self;
}

- (id)init
{
self = [super init];
if (self) {
// Uncomment to override the CDVCommandDelegateImpl used
// _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
// Uncomment to override the CDVCommandQueue used
// _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
}
return self;
}

- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

#pragma mark View lifecycle

- (void)viewWillAppear:(BOOL)animated
{
// View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
// you can do so here.

[super viewWillAppear:animated];
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

/* Comment out the block below to over-ride */

/*
- (UIWebView*) newCordovaViewWithFrame:(CGRect)bounds
{
return[super newCordovaViewWithFrame:bounds];
}
*/

@end

@implementation MainCommandDelegate

/* To override the methods, uncomment the line in the init function(s)
in MainViewController.m
*/

#pragma mark CDVCommandDelegate implementation

- (id)getCommandInstance:(NSString*)className
{
return [super getCommandInstance:className];
}

- (NSString*)pathForResource:(NSString*)resourcepath
{
return [super pathForResource:resourcepath];
}

@end

@implementation MainCommandQueue

/* To override, uncomment the line in the init function(s)
in MainViewController.m
*/
- (BOOL)execute:(CDVInvokedUrlCommand*)command
{
return [super execute:command];
}

@end

我是这样调用它的

MainViewController * layer = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];

谢谢

-艾美奖

最佳答案

尝试将 -ObjC 添加到目标的“其他链接器标志”。注意:cordova 文档说这是“-Obj-C”标志,不能解决问题。

https://cordova.apache.org/docs/en/latest/guide/platforms/ios/webview.html

关于ios - 将 cordova 添加到我现有的 ios 项目 : cordovaSettingForKey:]: unrecognized selector sent to instance 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36227026/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com