How can I speed up the getFirstResponder process?

When you first start the FirstResponder, it slows down. Tools measure about 160 ms ... By the time he downloaded everything he had to download to get the keyboard on the screen, the keyboard just appeared! Kills most of the smooth animation.

The second time, however, it quickly flares up! It only takes 2 ms!

So can I do it somehow?

+4
source share
1 answer

Using gcd

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // heavy lifting here dispatch_async(dispatch_get_main_queue(), ^{ [someTextField becomeFirstResponder]; }); }); 

This initially did not work as expected, but it was done after applying the GCD to some "uplift" that occurred in the background. In my case, it was a scroll view

 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // heavy lifting here dispatch_async(dispatch_get_main_queue(), ^{ [_tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; }); }); 
+2
source

Source: https://habr.com/ru/post/1492619/


All Articles