- [UIViewController _keyboard]:无法识别的选择器发送到实例0x7b731ac0 [英] -[UIViewController _keyboard]: unrecognized selector sent to instance 0x7b731ac0

查看:446
本文介绍了 - [UIViewController _keyboard]:无法识别的选择器发送到实例0x7b731ac0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



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



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



[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 - 菜单高度);
self.rightView.frame = CGRectMake((self.view.frame.size.width)/ 2,VIEWFRAMEOFFSET / 2,self.view.frame.size.width / 2,self.view.frame.size。高度 - 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,我就无法重新创建崩溃。



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



Stacktrace



  ***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' -  [FSSettingsViewController _keyboard]:无法识别的选择器发送到实例0x7da1dbf0'
***第一次抛出调用堆栈:

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键盘] + 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] + 31 6
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:以NSException类型的未捕获异常终止

这是Google机器第一次让我失望。在我制作这个应用程序的所有问题中,这是我似乎无法找到其他任何人的唯一问题。

解决方案

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



你似乎不幸的是,将一个属性命名为与Apple添加的属性相同的东西:

  @interface UIResponder(UIResponderInputViewAdditions)
//当对象成为第一响应者时调用并显示。走上响应者链。
@property(nonatomic,readonly,retain)UIInputViewController * inputViewController NS_AVAILABLE_IOS(8_0);
@end

当用户点击你的文字字段时,UIKit会抓住你的视图控制器认为它是 UIInputViewController 并发送私信 _keyboard 。您的视图控制器没有实现此方法,它会使应用程序崩溃。



您需要做的唯一事情是从 inputViewController重命名您的属性 myInputViewController 等其他内容。


I am writing an app with 3 viewControllers contained inside of a MainViewController. One of these is controlled through the storyboard and shows ads. The other two viewControllers are displaying information. Depending on the menu button pressed and the viewController to be presented the app determines which viewController to change.

So far everything is working well except when ANY textField is selected. This causes the error to display. The instance is the viewController containing the textField, and is also the UIViewController named in the error. Also, the instance is not nil. I've placed a breakpoint at: textFieldShouldBeginEditing:

and this method is called before the crash happens. The app is universal and doesn't crash on the iPhone version, which uses the same setup except it only has the ads and another viewController displayed. Let me know if you need to see more code or have any ideas. I can't find the selector _keyboard anywhere and have no idea what to do from here.

I've tried to create a new project with minimal code to show the error, but new projects all work fine, so the problem isn't having too many viewControllers visible at once. I also know my transitioning code works fine because it works in the new projects. The viewControllers I've written are also not the problem, because the exact same viewController is used in the iPhone part of the app as well as in a new iPad only test project and the problem doesn't show up on them at all.

[edit - removed code, I tested the code in a new project and it worked fine]

[edit2 - added code and explanation]

@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];
}

Selecting the textField causes this same error. I have literally commented out everything else in my MainViewController and it still causes this issue, but if I create a new project, even including my more complicated code and xib's, I can't recreate the crash.

Let me know if you want more code.

Stacktrace

*** 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

This is the first time the Google machine has let me down. In all the problems I've had making this app, this is the only problem I can't seem to find anyone else having.

解决方案

I'm going to assume this code works flawlessly when running on an iOS7 device and probably when compiled against the iOS7 SDK on an iOS8 device.

You appear to have had the misfortune of naming one of your properties the same thing as an Apple added property:

@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

When the user taps on your text field, UIKit will grab your view controller thinking it's a UIInputViewController and send the private message _keyboard. Your view controller doesn't implement this method and it crashes the app.

The only thing you need to do here is rename your property from inputViewController to something else like myInputViewController.

这篇关于 - [UIViewController _keyboard]:无法识别的选择器发送到实例0x7b731ac0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆