Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 390 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Super slow lag/delay on initial keyboard animation of UITextField

#1


It takes roughly 3-4 seconds for the keyboard to pop up after I touch my `UITextField`. This only occurs on the first time the keyboard pops up since the app launched, afterwards the animation starts instantly.

At first I thought it was problem of loading too many images, or my `UITableView`, but I just created a brand new project with only a `UITextField`, and I still experience this problem. I'm using iOS 5, Xcode ver 4.2, and running on an iPhone 4S.

This is my code:

#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 20, 280, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.delegate = self;
[self.view addSubview:textField];
}

@end

Is this a common problem for all apps?

Right now, the only way I can make it somewhat better is by having `textField` become/resign first responder in `viewDidAppear`, but that doesn't solve the problem entirely - it just loads the delay onto when the view loads instead. If I click on `textField` immediately when the view loads, I still get the problem; if I wait 3-4 seconds after the view loads before touching the textField, I don't get the delay.
Reply

#2
Yeah, I also got a few seconds delay on the latest iPhone 4s. Don't panic. For some reasons, it only happens the first time the app is loaded from Xcode in Debug. When I did Release, I don't get the delay. Just forget it...
Reply

#3
So the problem is NOT just limited to the first install as I had previously thought, but happens every time the app is launched. Here's my solution that solves the issue completely.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Preloads keyboard so there's no lag on initial keyboard appearance.
UITextField *lagFreeField = [[UITextField alloc] init];
[self.window addSubview:lagFreeField];
[lagFreeField becomeFirstResponder];
[lagFreeField resignFirstResponder];
[lagFreeField removeFromSuperview];
}
Reply

#4
Before you implement any exotic hacks to get around this problem, try this: stop the debug session, close the app from multitasking, unplug your device from the computer and run the app normally by tapping its icon. I have seen at least two cases in which the delay only occurs while the device is plugged in.
Reply

#5
You can add below code when viewController's view did loaded, like viewDidAppear.Not just application:didFinishLaunchingWithOptions:

UITextField *lagFreeField = [[UITextField alloc] init];
[self.window addSubview:lagFreeField];
[lagFreeField becomeFirstResponder];
[lagFreeField resignFirstResponder];
[lagFreeField removeFromSuperview];

Reply

#6
Code in block added to main queue and run asynchronously. (don't locked main thread)

dispatch_async(dispatch_get_main_queue(), ^(void){
[textField becomeFirstResponder];
});
Reply

#7
This bug seems to be fixed in iOS 9.2.1. Since upgrading my device, I no longer have a delay between tapping a text field and the keyboard appearing when my device is connected to my computer.
Reply

#8
You can use Vadoff's solution in Swift by adding this to didFinishLaunchingWithOptions:

// Preloads keyboard so there's no lag on initial keyboard appearance.
let lagFreeField: UITextField = UITextField()
self.window?.addSubview(lagFreeField)
lagFreeField.becomeFirstResponder()
lagFreeField.resignFirstResponder()
lagFreeField.removeFromSuperview()

It is working for me in iOS 8.

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through