将输入视图添加到textfield iOS 8时出错 [英] Error when adding input view to textfield iOS 8

查看:224
本文介绍了将输入视图添加到textfield iOS 8时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在iOS 8上为我的应用添加自定义输入视图时,我遇到了问题。这在iOS 7上完全正常,但是当切换到iOS 8时,一切都失败了。

I'm having an issue when I add a custom input view to my app on iOS 8. This was working perfectly fine on iOS 7 but when switching to iOS 8 everything fails.

这是堆栈跟踪:

2014-06-03 21:23:54.237 MyApp[1910:47245] *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UICompatibilityInputViewController: 0x1103f9d40>
should have parent view controller:<StopChooser: 0x11083e200> but requested parent is:<UIInputWindowController: 0x110858800>'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001042eee35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000103b919a0 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001042eed6d +[NSException raise:format:] + 205
    3   UIKit                               0x00000001023d94cd -[UIViewController _addChildViewController:performHierarchyCheck:notifyWillMove:] + 184
    4   UIKit                               0x0000000102977a2b -[UIInputWindowController changeToInputViewSet:] + 416
    5   UIKit                               0x0000000102973f56 -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 185
    6   UIKit                               0x000000010297826a -[UIInputWindowController setInputViewSet:] + 526
    7   UIKit                               0x0000000102973c97 -[UIInputWindowController performOperations:withAnimationStyle:] + 50
    8   UIKit                               0x00000001027559bb -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1054
    9   UIKit                               0x0000000102422afd -[UIResponder becomeFirstResponder] + 468
    10  UIKit                               0x00000001023235d3 -[UIView(Hierarchy) becomeFirstResponder] + 99
    11  UIKit                               0x00000001029cdbfb -[UITextField becomeFirstResponder] + 51
    12  UIKit                               0x0000000102655d61 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 177
lib: terminating with uncaught exception of type NSException
    (lldb) 

相关部分是前几行。有人可以解释一下吗?我正在调用的是 myTextview.inputView = keyboard ;键盘是在故事板中创建并通过IBOutlet链接的UIView。

The relevant part being the top few lines. Can someone explain this? All I'm calling is myTextview.inputView = keyboard; Keyboard being a UIView created in the storyboard and linked via IBOutlet.

推荐答案

之前我遇到过这个问题。

I encountered this problem before.

问题


  • 你必须确保您将分配给 inputView inputAccessoryView 的视图不属于任何父视图。当您从ViewController中的xib创建这些视图时,默认情况下它们被设置为superview的子视图。

  • You have to ensure that the view you will assign to inputView or inputAccessoryView doesn't belong to any parent view. When you create these views from a xib inside a ViewController, by default they are set as subviews of a superview.

解决方案提示


  • 在视图上使用方法 removeFromSuperview 分配给 inputView inputAccessoryView

  • Use the method removeFromSuperview on the view you will assign to inputView or inputAccessoryView

这篇关于将输入视图添加到textfield iOS 8时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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