gpt4 book ai didi

ios - 当调用 becomeFirstResponder 时,UITextView 使应用程序崩溃

转载 作者:可可西里 更新时间:2023-11-01 17:04:01 27 4
gpt4 key购买 nike

我在 UITextView 中有一个 UIView 。当 viewLoad 时,我在带有 "OK" 按钮的 UIPickerView 中有一个 UIAlertView。当我从选取器中选择任何值并单击“确定”时,我需要激活UITextView
为此,我编写了 [<myTextView> becomeFirstResponder];UITextView 委托(delegate)方法。一旦执行此方法,它就会调用 textViewShouldBeginEditing 委托(delegate)方法。此方法正确执行,我在这里返回 TRUE,但之后执行返回到 [<myTextView> becomeFirstResponder]; 行,然后应用程序崩溃。
UIAlertView 委托(delegate)方法如下:

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

在上面的代码中,应用程序在 [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] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.071223 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.072122 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.132574 oGoing[250:11235] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2016-12-09 11:47:53.136872 oGoing[250:11235] [MC] Reading from public effective user settings.
2016-12-09 11:47:53.370813 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.372515 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.372781 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.373559 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.373942 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.374133 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.374921 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00>
2016-12-09 11:47:53.477836 oGoing[250:11235] *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UICompatibilityInputViewController: 0x6e208f0> should have parent view controller:<OGAddUpdateViewController: 0x17bebe00> but requested parent is:<UIInputWindowController: 0x17b81400>'
*** First throw call stack:
(0x1c38de07 0x1b5f3077 0x1c38dd4d 0x2146dd8b 0x21d43ba3 0x21d448cd 0x213e11bb 0x21d44655 0x21d3d1c9 0x21497b8f 0x213f9153 0x21456e15 0x21457181 0x2157ff83 0x1b04f5 0x287bb5 0x2140895d 0x214088eb 0x213f2a87 0x21408213 0x21407d5f 0x21402947 0x213d37c9 0x21b73c39 0x21b6d8db 0x1c349c8b 0x1c349795 0x1c347a6b 0x1c297073 0x1c296e81 0x1da3fbfd 0x2143eacf 0x21439201 0xed585 0x1ba6250b)
libc++abi.dylib: terminating with uncaught exception of type NSException

帮我摆脱这一切。自 2 天以来,我一直被困在这个问题上。
我的项目已经在 AppStore 上,并且运行正常。但是当我在 iOS 10 设备上运行它时,它会产生这个问题。

提前致谢

最佳答案

尝试这个它正在工作......

我以前遇到过这个问题。

问题:

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

解决方法:

在要分配给 inputView 或 inputAccessoryView 的 View 上使用方法 removeFromSuperview

来自:https://stackoverflow.com/a/25882277/3901620

同时来自 xib :

[self.DatePickerView removeFromSuperview];
[Textfield setInputView:self.DatePickerView];
[Textfield setInputView:self.DatePickerView];

关于ios - 当调用 becomeFirstResponder 时,UITextView 使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41054274/

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