当我在iOS 8上为我的应用程序添加一个自定义输入视图时,我遇到了一个问题。这在iOS 7上非常好,但是当切换到iOS 8时,一切都失败了。
这是堆栈跟踪:
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。
发布于 2014-09-17 04:23:10
我以前遇到过这个问题。
问题:
inputView或inputAccessoryView的视图不属于任何父视图。当您从ViewController内部的xib创建这些视图时,默认情况下它们被设置为superview的子视图。解决方案提示
inputView或inputAccessoryView的视图上使用方法inputAccessoryView发布于 2014-09-22 06:58:06
在becomeFirstResponder删除从superview中输入的视图之前:
mTextField.inputView = mInputVeiw;
[mInputVeiw removeFromSuperview];
[mTextField becomeFirstResponder];希望能帮上忙。
发布于 2015-05-28 01:34:58
您必须确保分配给
inputView或inputAccessoryView的视图不属于任何父视图。
这个错误特别恼人,因为在故事板中创建的任何“输入视图”(因此添加到VC的view中)都不能被设置为inputView或inputAccessoryView,而不会导致此崩溃。
如果未将输入视图添加到VC的view中,则无法在中对输入视图进行可视化编辑。只有在故事板的左窗格中才能看到。
How to connect Xcode Storyboard's "Simulated Metrics" toolbar to an actual IBOutlet UIToolbar?
我更愿意在故事板中直接连接到inputAccessoryView。导致这次坠机。我找到的一个解决方案是使第二个IBOutlet连接到Storyboard中的视图,然后在viewDidLoad中将其从超级视图中删除,然后立即分配给inputAccessoryView。不知道我会不会用这个。
- (void)viewDidLoad {
// ...
[self.keybordView removeFromSuperview];
self.inputAccessoryView = self.keybordView;
}https://stackoverflow.com/questions/24029113
复制相似问题