zoukankan      html  css  js  c++  java
  • iOS判断当前键盘是不是手写键盘

    // 思路:判断有没有UIKBHandwritingView,遍历所有view

    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

    {

    #warning 担心苹果改变键盘结构,没有取到UIKBHandwritingView;造成无法消费!

     

        NSString *yuan = @"邓超界";

        if (![string isEqualToString:yuan]) {

            [SVProgressHUD showErrorWithStatus:@"签名不是持卡人姓名,请重写;如果不是手写键盘,请长按或者点击键盘上左下角的地球图标,选择 简体手写"];

            textField.text = @"";

            return NO;

        }

        if ([string isEqualToString:@" "]) {

            return NO;

        }

        // 判断有没有UIKBHandwritingView  遍历所有view

        UIView *handwritingView;

        for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) {

            if ([[keyboardWindow description] hasPrefix:@"<UIRemoteKeyboardWindow"] == YES) {

                for (UIView *setContainer in keyboardWindow.subviews) {

                    if ([[setContainer description] hasPrefix:@"<UIInputSetContainerView"] == YES) {

                        for (UIView *setHost in setContainer.subviews) {

                            if ([[setHost description] hasPrefix:@"<UIInputSetHostView"] == YES) {

                                for (UIView *compat in setHost.subviews) {

                                    if ([[compat description] hasPrefix:@"<_UIKBCompatInputView"] == YES) {

                                        for (UIView *automatic in compat.subviews) {

                                            if ([[automatic description] hasPrefix:@"<UIKeyboardAutomatic"] == YES) {

                                                for (UIView *lmpl in automatic.subviews) {

                                                    if ([[lmpl description] hasPrefix:@"<UIKeyboardImpl"] == YES) {

                                                        for (UIView *layoutStar in lmpl.subviews) {

                                                            if ([[layoutStar description] hasPrefix:@"<UIKeyboardLayoutStar"] == YES) {

                                                                for (UIView *plane in layoutStar.subviews) {

                                                                    if ([[plane description] hasPrefix:@"<UIKBKeyplaneView"] == YES) {

                                                                        for (UIView *view in plane.subviews) {

                                                                            if([[view description] hasPrefix:@"<UIKBHandwritingView"] == YES){

                                                                                handwritingView = view;

                                                                                break;

                                                                            }

                                                                        }

                                                                        break;

                                                                    }

                                                                }

                                                                break;

                                                            }

                                                        }

                                                        break;

                                                    }

                                                }

                                                break;

                                            }

                                        }

                                        break;

                                    }

                                }

                                break;

                            }

                        }

                        break;

                    }

                }

                break;

            }

        }

     

        if (handwritingView) {

            // 截屏

            [self printscreenOfView:handwritingView];

            [SVProgressHUD showSuccessWithStatus:@"签名正确"];

        }else

        {

            [SVProgressHUD showInfoWithStatus:@"请长按或者点击键盘上左下角的地球图标,切换键盘为 简体手写"];

            textField.text = @"";

            return NO;

        }

        return YES;

    }

  • 相关阅读:
    MySQL 索引相关
    MySQL 事务操作
    MySQL 分支循环
    详细实例教程!集成华为虚假用户检测,防范虚假恶意流量
    快速集成华为AGC云存储服务-NodeJS
    随心译——无广告的专属实时翻译神器
    如何实现情景式精准触达用户,提高用户活跃与转化?
    快速集成华为AGC-AppLinking服务-iOS平台
    华为联运游戏或应用审核驳回:点击登录进入游戏,未显示欢迎栏
    视频App如何使用无线传输服务获得更好的播放体验
  • 原文地址:https://www.cnblogs.com/dengchaojie/p/7866935.html
Copyright © 2011-2022 走看看