简体   繁体   English

UITextView由于EXC错误访问而成为FirstResponder崩溃

[英]UITextView becomeFirstResponder crash with EXC bad access

I have a UIViewController with UITextView in the storyboard I assigned it with strong variable.The first time when I present the ViewController using story board segue there is no crash but when I dismiss the ViewController and again present the ViewController for the second time after [UITextView becomeFirstResponder] is called the app crashes and shows the following error 我在故事板上有一个带有UITextViewUIViewController并为其分配了强变量。第一次使用故事板segue呈现ViewController时,没有崩溃,但是当我关闭ViewController并在[UITextView becomeFirstResponder]之后[UITextView becomeFirstResponder]再次第二次呈现ViewController时, [UITextView becomeFirstResponder]被称为应用程序崩溃并显示以下错误

[UIViewController _responderWindow]: message sent to deallocated instance

I have assigned delegate to the ViewController in which the TextView is added and implemented all the delegate methods 我已将委托分配给添加了TextView的ViewController并实现了所有委托方法

I tried calling this method [UITextview becomeFirstResponder] after a delay but no use it was still crashing 我尝试在延迟后调用此方法[UITextview becomeFirstResponder] ,但没有使用,它仍然崩溃

I tried profiling with zombie template the error is in UIKit 我尝试使用僵尸模板进行分析,但错误是在UIKit

this is the response I am getting when the app crashed if enable zombies in the product scheme 如果在产品方案中启用僵尸,这是我在应用程序崩溃时得到的响应

[ReviewViewController _responderWindow]: message sent to deallocated instance 0x14ed3a2a0

this is the code I am using to present the viewcontroller which has the textview 这是我用来呈现具有textview的viewcontroller的代码

[_promotionsViewControllerDelegate performSegueWithIdentifier:@"testing" sender:nil];

textview viewcontroller TextView ViewController

  - (void)viewDidLoad { 
        [super viewDidLoad];
        _reviewTextView.delegate = self;
        [_reviewTextView becomeFirstResponder];
        }

this is the back trace error log when i run the application without zombies 这是我没有僵尸运行应用程序时的追溯跟踪错误日志

* thread #1: tid = 0x758d4, 0x000000019271bbd0 libobjc.A.dylib`objc_msgSend + 16, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x174697260)
    frame #0: 0x000000019271bbd0 libobjc.A.dylib`objc_msgSend + 16
    frame #1: 0x000000018675f96c UIKit`-[UIView(Internal) _firstResponder] + 24
    frame #2: 0x000000018675f940 UIKit`-[UIResponder isFirstResponder] + 32
    frame #3: 0x0000000186e96ed8 UIKit`-[UITextView _keyboardDidShow:] + 32
    frame #4: 0x0000000181f58ae4 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
    frame #5: 0x0000000181e97220 CoreFoundation`_CFXNotificationPost + 2060
    frame #6: 0x0000000182d96cc0 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 72
    frame #7: 0x0000000186e5f458 UIKit`-[UIInputWindowController postEndNotifications:withInfo:] + 580
    frame #8: 0x0000000186e60c7c UIKit`__77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke595 + 396
    frame #9: 0x000000018679c0a4 UIKit`-[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 408
    frame #10: 0x000000018679bc0c UIKit`-[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 188
    frame #11: 0x000000018679bb14 UIKit`-[UIViewAnimationState animationDidStop:finished:] + 104
    frame #12: 0x00000001860c0f64 QuartzCore`CA::Layer::run_animation_callbacks(void*) + 296
    frame #13: 0x00000001002b4df0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #14: 0x00000001002b975c libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1056
    frame #15: 0x0000000181f69fa4 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    frame #16: 0x0000000181f6804c CoreFoundation`__CFRunLoopRun + 1492
    frame #17: 0x0000000181e950a4 CoreFoundation`CFRunLoopRunSpecific + 396
    frame #18: 0x000000018b0375a4 GraphicsServices`GSEventRunModal + 168
    frame #19: 0x00000001867ca3c0 UIKit`UIApplicationMain + 1488
  * frame #20: 0x00000001000c1030 WineDisciples`main(argc=1, argv=0x000000016fd83a58) + 116 at main.m:14
    frame #21: 0x0000000192d76a08 libdyld.dylib`start + 4

I Kindly request you to help me on this thanks.. 谨在此感谢您的帮助。

Did you check your Identifier in inspector window similar to given in code (ie "testing" )? 您是否在检查器窗口中检查了与代码中给定的标识符类似的标识符(即“测试”)?

Also in your .h file had you given the . 同样在.h文件中,您给了。 If not then add it. 如果没有,则添加它。

Maybe is too late, but I had the same problem and the solution was to send remove from superview in the dealloc method of my vwc 也许为时已晚,但是我遇到了同样的问题,解决方案是在我的vwc的dealloc方法中从superview发送remove

deinit {
    self.commentTextView.delegate = nil
    self.commentTextView.removeFromSuperview()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM