zoukankan      html  css  js  c++  java
  • UITextField next/go, keyboard delay

    问题一: 

    总共三个UITextField, originalPwd/inputedPwd 键盘显示next,confirmedPwd键盘显示Go:

    @property (weak, nonatomic) IBOutlet UITextField *originalPwd;
    @property (weak, nonatomic) IBOutlet UITextField *inputedPwd;
    @property (weak, nonatomic) IBOutlet UITextField *confirmedPwd;
    

    但是键盘上的next和go根本没有反应,在UITextFieldDelegate方法 textFieldShouldReturn加断点不进入。

    解决:经检查,翻了一个低级错误,没有设置UITextField的delegate。。。。。。

    问题二:

    第一次点击UITextField时keyboard延迟大概3s,难以接受。

    解决:在viewDidLoad中加入以下打码

       UITextField *field = [UITextField new];
        [[[[UIApplication sharedApplication] windows] lastObject] addSubview:field];
        [field becomeFirstResponder];
        [field resignFirstResponder];
        [field removeFromSuperview];
    

    ps:虽然keyboard不延迟了,但是整个View第一次加载延迟了, 改成如下:

        // resolve keyboard delay
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.0), dispatch_get_main_queue(), ^{
            UITextField *field = [UITextField new];
            [[[[UIApplication sharedApplication] windows] lastObject] addSubview:field];
            [field becomeFirstResponder];
            [field resignFirstResponder];
            [field removeFromSuperview];
        });
    

      

  • 相关阅读:
    c# 移动winform窗体
    C# 通过反射动态创建对象的方法
    C# listView用法
    C# PropertyGrid总结
    C# 静态或动态调用C++动态链接库dll
    C# 加载C++创建的动态链接库dll
    C# 动态加载dll(.net)示例
    C# 关于泛型
    C# 中的指针使用
    C/S与B/S的区别
  • 原文地址:https://www.cnblogs.com/1oo1/p/3891513.html
Copyright © 2011-2022 走看看