HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – UITextField代理跳到100%CPU使用率,并使用键盘快捷键崩溃大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
所以,我有一个UITextField子类,它是自己的Delegate,并且当使用键盘快捷键时崩溃.它最多在cpu上,不会发生错误.没有分配自己作为代表,它的工作没有问题.当它被分配为委托时,即使不使用(可选)方法也会崩溃.

自己尝试一下:

子类UITextField.

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        self.delegate = self;

    }
    return self;
}

它应该崩溃

编辑
回溯:

* thread #1: tid = 0x3bb8d,0x39f14726 libobjc.A.dylib`lookUpImpOrNil + 18,queue = 'com.apple.main-thread,stop reason = signal SIGSTOP
    frame #0: 0x39f14726 libobjc.A.dylib`lookUpImpOrNil + 18
    frame #1: 0x39f0dcb6 libobjc.A.dylib`class_respondsToSELEctor + 34
    frame #2: 0x39f1d05c libobjc.A.dylib`-[NSObject respondsToSELEctor:] + 32
    frame #3: 0x323b9242 UIKit`-[UITextField respondsToSELEctor:] + 46
    frame #4: 0x325c88a2 UIKit`-[UITextField customOverlayContainer] + 50
    frame #5: 0x325c8730 UIKit`-[UITextField automaticallySELEctedOverlay] + 28
    frame #6: 0x32554208 UIKit`-[UIKeyboardImpl inputOverlayContainer] + 424
    frame #7: 0x32553942 UIKit`-[UIKeyboardImpl _autocorrectPromptRects] + 454
    frame #8: 0x323c7530 UIKit`-[UIKeyboardImpl updateAutocorrectPrompt:] + 368
    frame #9: 0x323e63e0 UIKit`-[UIDelayedAction timerFired:] + 80
    frame #10: 0x305fbe6c Foundation`__NSFireTimer + 64
    frame #11: 0x2fbe1e86 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
    frame #12: 0x2fbe1aa2 CoreFoundation`__CFRunLoopDoTimer + 794
    frame #13: 0x2fbdfe2a CoreFoundation`__CFRunLoopRun + 1218
    frame #14: 0x2fb4a540 CoreFoundation`CFRunLoopRunSpecific + 524
    frame #15: 0x2fb4a322 CoreFoundation`CFRunLoopRunInMode + 106
    frame #16: 0x348812ea Graphicsservices`GSEventRunModal + 138
    frame #17: 0x324011e4 UIKit`UIApplicationMain + 1136
    frame #18: 0x0009929c Today`main(argc=1,argv=0x27d79c80) + 164 at main.m:29

解决方法

在使用自委托的UITextField子类时,我遇到同样的问题.如果不可能将委托人更改为自己以外的其他东西,我建议覆盖respondToSELEctor,而不是实现一个可能返回无效对象的customOverlayContainer方法(你确定它应该是UITextField的一个实例吗?你如何知道iOS不要求UIView或CGLayer或任何其他类型的对象?)
-(BOOL) respondsToSELEctor:(SEL)aSELEctor {

    NSString * SELEctorName = NSStringFromSELEctor(aSELEctor);

    if ([SELEctorName isEqualToString:@"customOverlayContainer"]) {

        NSLog(@"prevenTing self.delegate == self crash");

        return NO;
    }

    return [super respondsToSELEctor:aSELEctor];
}

大佬总结

以上是大佬教程为你收集整理的ios – UITextField代理跳到100%CPU使用率,并使用键盘快捷键崩溃全部内容,希望文章能够帮你解决ios – UITextField代理跳到100%CPU使用率,并使用键盘快捷键崩溃所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。