Giter Club home page Giter Club logo

customkeyboard's Issues

空格键第一次不高亮问题---解决方案

按钮点击事件不会使背景颜色发生改变,所以你在点击空格键的时候加了修改按钮背景颜色的方法,这时已经点击了按钮,但是不会调用点击事件
所以解决方案是,在遍历子view的时候加上就可以了
LDDKeyboardView.m文件下

//设置各个键盘View上的按钮点击方法
-(void)setupButtonClickWithView:(UIView*)view{
    
    [view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        //按钮类型是CYRKeyboardButton,则点击按钮时有extension
        if ([obj isKindOfClass:[CYRKeyboardButton class]]) {
            CYRKeyboardButton *cyrButton=(CYRKeyboardButton*)obj;
            cyrButton.input=cyrButton.currentTitle;
            //cyrButton.inputOptions=@[@"A",@"B",@"C",@"D"];
            [cyrButton addTarget:self action:@selector(keyboardBtnClick:) forControlEvents:UIControlEventTouchUpInside];
            //按钮类型是UIButton,直接执行点击方法
        }else if ([obj isKindOfClass:[UIButton class]]){
            UIButton *button=(UIButton*)obj;
            [button addTarget:self action:@selector(keyboardBtnClick:) forControlEvents:UIControlEventTouchUpInside];
#pragma mark - 此处为新增代码
            //设置空格按钮状态
            if (button.tag == LDDButtonTypeSpace) {
                [button addTarget:self action:@selector(backgroundHighlighted:) forControlEvents:UIControlEventTouchDown];
                //需要再将按钮置为正常背景色
                [button addTarget:self action:@selector(backgroundNormal:) forControlEvents:UIControlEventTouchUpOutside];
            }   
        }
    }];
}

同时感谢大佬贡献的代码

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.