您的位置:首页 > 移动开发

iOS App键盘第一次启动延迟问题

2015-09-21 20:35 393 查看
其实这不是一个问题,拔掉USB数据线,断开设备连接后,手动点击App图标以正常模式运行后会发现原来键盘的唤出速度是很快的。

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.

有网友通过下面的方式解决,虽然有点画蛇添足,但是至少调试方便。(因为键盘延迟这种情况只会在连机调试的时候出现)

- (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];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iOS 键盘 速度