StartFirstResponder slows down the application when displaying

This is a continuation of this problem: startFirstResponder slows down the application

I am experiencing the same problem as this poster, i.e. calling startFirstResponder slows down my application (it freezes, maybe 1-2 seconds). However, while they called it along with a warning, I was just trying to display a hidden view and appear with a specific field as the first responder. Sort of:

[self.dialogView setHidden:NO]; [self.dialogText becomeFirstResponder]; 

The dialog box has a hierarchy containing dialogText (UITextField, which I am trying to set as the first responder) and some other elements.

This slowness is shown only at the first start of this code, that is, for the first time, when we try to open this dialog box. In subsequent attempts, there is no obvious slowness (I assume this is because dialogText is already the first responder at this point - have I used resignFirstResponder somewhere?).

Edit: here is some additional code for the context, but not sure if it really sheds light. Note. Now I am animating the invisibility of this dialog box, however the behavior is no different. I have also since transferred the call to getFirstResponder to a termination block (not reflected in the code here), so that at least the appearance of the dialog is not delayed, however, there is still a delay between the appearance of the dialog and the keyboard.

 - (IBAction)showEditDialog:(id)sender { [UIView animateWithDuration:0.3f animations:^() { self.maskView.alpha = 0.8; self.editDialogView.alpha = 1.0; } completion:^(BOOL finished) { if (finished) { } }]; [self.editDialogText becomeFirstResponder]; } 
+4
source share
1 answer

firstly, you switch the view (e.g. view1 (hide) โ†’ view2 (show))

If you have a dialogText dialog (which I assume is a text field?) In another view, I suggest you:

 [self.view bringSubviewToFront:view2]; 

first

It is hard to guess what slows down without looking at how your views stand out and where text or text fields sit.

+2
source

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


All Articles