当我在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 …Run Code Online (Sandbox Code Playgroud) 我有UITextView一个UIView.当viewLoad,我有一个UIPickerView内UIAlertView有"OK"按钮.当我从选择器中选择任何值并单击"确定"时,我需要激活UITextView.
为此我写了[<myTextView> becomeFirstResponder];委托方法UITextView.只要此方法执行它textViewShouldBeginEditing,就会调用委托方法.这个方法正确执行,我在这里返回TRUE,但之后执行返回到该行[<myTextView> becomeFirstResponder];,然后应用程序崩溃.
UIAlertView委托方法如下:
- (void)customIOS7dialogButtonTouchUpInside: (CustomIOS7AlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex
{
NSLog(@"Button at position %d is clicked on alertView %d.", (int)buttonIndex, (int)[alertView tag]);
[alertView close];
[self.updateTV becomeFirstResponder];
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码应用程序崩溃[self.updateTV becomeFirstResponder];
崩溃日志显示如下:
2016-12-09 11:47:53.069049 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.069451 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.070530 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.070970 oGoing[250:11235] …Run Code Online (Sandbox Code Playgroud)