简体   繁体   中英

UITextField / UITextView - iOS 11 - High CPU Usage

I think that I found a bug in iOS 11 with Objective-C. If you create an empty project with tons of textfields or text views, you'll see the CPU usage out of control. Through Instruments I discovered that the event that make the cursor / caret blinks keep being called, even if you deallocate the textfields.

I have a big project with 2 textfields in each row of a table and I really don't know how to fix it. Ironically, this event is being called even if you don't see the blinking cursor.

Anyone faced this problem?

Here it is what is being called:

 Main Thread
      start
           0x100b2fcde
                UIApplicationMain
                     GSEventRunModal
                          CFRunLoopRunSpecific
                               _CFRunLoopRun
                                    _CFRunLoopDoTimer
                                         _DFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION_
                                              _NFFireTimer
                                                   -[UITextSelectionView caretBlinkTimerFired:]
                48%                                    - [UITextSelectionView showCaret:]
                48%                                   -[UITextSelectView hideCaret:]

PS I tried the same program on iOS 10.3 and it works fine.

在Apple修复该问题之前,我看到用空白字符串@“”替换文本字段文本可以解决此问题。

With iOS update 11.1, problem seems to be resolved, according to my tests. With this update, when a UITextView or UITexField loses focus, CPU usage decreases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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