gpt4 book ai didi

ios - -[UIViewController_keyboard] : unrecognized selector sent to instance 0x7b731ac0

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:51:49 24 4
gpt4 key购买 nike

我正在编写一个应用程序,其中包含一个 MainViewController 中的 3 个 viewController。其中之一通过 Storyboard控制并显示广告。另外两个 viewController 正在显示信息。根据按下的菜单按钮和要显示的 viewController,应用程序确定要更改的 viewController。

到目前为止,除了选择了 ANY textField 之外,一切都运行良好。这会导致显示错误。实例是包含textField的viewController,也是报错中命名的UIViewController。此外,该实例不是零。我在以下位置放置了一个断点:textFieldShouldBeginEditing:

并且此方法在崩溃发生之前被调用。该应用程序是通用的,不会在 iPhone 版本上崩溃,iPhone 版本使用相同的设置,只是它只显示广告和另一个 viewController。如果您需要查看更多代码或有任何想法,请告诉我。我在任何地方都找不到选择器 _keyboard,也不知道从这里可以做什么。

我试图用最少的代码创建一个新项目来显示错误,但新项目都运行良好,所以问题不是一次可见太多 viewController。我也知道我的转换代码工作正常,因为它在新项目中工作。我编写的 viewControllers 也不是问题,因为在应用程序的 iPhone 部分以及新的 iPad 测试项目中使用了完全相同的 viewController,并且问题根本没有出现在它们身上。

[编辑 - 删除了代码,我在一个新项目中测试了代码,它运行良好]

[edit2 - 添加代码和解释]

@implementation FSMainiPadViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.leftView = [[UIView alloc] init];
self.rightView = [[UIView alloc] init];

if (!self.testVC) {
self.testVC = [[FSTestViewController alloc] initWithNibName:nil bundle:nil];
}
self.inputViewController = self.testVC;

self.resultsVC = [[FSResultsTableViewController alloc] initWithNibName:nil bundle:nil];
self.dataViewController = self.resultsVC;


self.leftView.frame = CGRectMake(0, VIEWFRAMEOFFSET/2, self.view.frame.size.width/2 , self.view.frame.size.height - IPADBANNERHEIGHT - VIEWFRAMEOFFSET/2 - MENUHEIGHT);
self.rightView.frame = CGRectMake((self.view.frame.size.width)/2, VIEWFRAMEOFFSET/2, self.view.frame.size.width/2, self.view.frame.size.height - IPADBANNERHEIGHT - VIEWFRAMEOFFSET/2 - MENUHEIGHT);


[self addChildViewController:self.inputViewController];
[self addChildViewController:self.dataViewController];
[self.view addSubview:self.inputViewController.view];
[self.view addSubview:self.dataViewController.view];
[self.dataViewController didMoveToParentViewController:self];
[self.inputViewController didMoveToParentViewController:self];
}

选择 textField 会导致同样的错误。我实际上已经注释掉了我的 MainViewController 中的所有其他内容,它仍然会导致这个问题,但是如果我创建一个新项目,即使包括我更复杂的代码和 xib,我也无法重现崩溃。

如果您需要更多代码,请告诉我。

堆栈跟踪

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FSSettingsViewController _keyboard]: unrecognized selector sent to instance 0x7da1dbf0'
*** First throw call stack:
(
0 CoreFoundation 0x0326d946 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x02ef6a97 objc_exception_throw + 44
2 CoreFoundation 0x032755c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x031be3e7 ___forwarding___ + 1047
4 CoreFoundation 0x031bdfae _CF_forwarding_prep_0 + 14
5 UIKit 0x01e46d91 -[UIInputViewSet keyboard] + 52
6 UIKit 0x01b0807c -[UIKeyboardImpl setOrientation] + 94
7 UIKit 0x01b082c8 -[UIKeyboardImpl setFrame:] + 197
8 UIKit 0x01939084 UIViewCommonInitWithFrame + 1072
9 UIKit 0x01938bea -[UIView initWithFrame:] + 124
10 UIKit 0x01b02b62 -[UIKeyboardImpl initWithFrame:] + 107
11 UIKit 0x01b01c58 +[UIKeyboardImpl sharedInstance] + 158
12 UIKit 0x01e3bf4f -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 962
13 UIKit 0x01a845a5 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 316
14 UIKit 0x01a838ec -[UIResponder becomeFirstResponder] + 562
15 UIKit 0x0194a1c0 -[UIView(Hierarchy) becomeFirstResponder] + 114
16 UIKit 0x02115477 -[UITextField becomeFirstResponder] + 51
17 UIKit 0x01d183ef -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 200
18 UIKit 0x01d1aa16 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2762
19 UIKit 0x01d0e287 _UIGestureRecognizerSendActions + 327
20 UIKit 0x01d0cb04 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 561
21 UIKit 0x01d0eb4d -[UIGestureRecognizer _delayedUpdateGesture] + 60
22 UIKit 0x01d124ca ___UIGestureRecognizerUpdate_block_invoke661 + 57
23 UIKit 0x01d1238d _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
24 UIKit 0x01d06296 _UIGestureRecognizerUpdate + 3720
25 UIKit 0x0191f26b -[UIWindow _sendGesturesForEvent:] + 1356
26 UIKit 0x019200cf -[UIWindow sendEvent:] + 769
27 UIKit 0x018e5549 -[UIApplication sendEvent:] + 242
28 UIKit 0x018f537e _UIApplicationHandleEventFromQueueEvent + 20690
29 UIKit 0x018c9b19 _UIApplicationHandleEventQueue + 2206
30 CoreFoundation 0x031911df __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
31 CoreFoundation 0x03186ced __CFRunLoopDoSources0 + 253
32 CoreFoundation 0x03186248 __CFRunLoopRun + 952
33 CoreFoundation 0x03185bcb CFRunLoopRunSpecific + 443
34 CoreFoundation 0x031859fb CFRunLoopRunInMode + 123
35 GraphicsServices 0x0519f24f GSEventRunModal + 192
36 GraphicsServices 0x0519f08c GSEventRun + 104
37 UIKit 0x018cd8b6 UIApplicationMain + 1526
38 FoodStorage 0x000a795d main + 141
39 libdyld.dylib 0x04e14ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是谷歌机器第一次让我失望。在我制作此应用程序时遇到的所有问题中,这是我似乎找不到其他任何人遇到的唯一问题。

最佳答案

我假设这段代码在 iOS7 设备上运行时可以完美运行,并且可能在 iOS8 设备上针对 iOS7 SDK 进行编译。

您似乎不幸将您的一个属性命名为与 Apple 添加的属性相同的名称:

@interface UIResponder (UIResponderInputViewAdditions)
// Called and presented when object becomes first responder. Goes up the responder chain.
@property (nonatomic, readonly, retain) UIInputViewController *inputViewController NS_AVAILABLE_IOS(8_0);
@end

当用户点击您的文本字段时,UIKit 将捕获您的 View Controller ,认为它是一个 UIInputViewController 并发送私有(private)消息 _keyboard .您的 View Controller 未实现此方法,它会导致应用程序崩溃。

您在这里唯一需要做的就是将您的属性从 inputViewController 重命名为其他名称,例如 myInputViewController

关于ios - -[UIViewController_keyboard] : unrecognized selector sent to instance 0x7b731ac0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27930743/

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