“下一步”按钮自定义键盘Objective-C

时间:2017-04-02 18:07:11

标签: ios objective-c keyboard

我使用Objective-C创建了一个自定义键盘。但是,我坚持使用某个功能,并且能够实现类似于iOS键盘上已有的“下一步”按钮。 (我在下面附上了iOS键盘的屏幕截图)。

这是我的键盘视图控制器代码,它将我的按钮空白连接到实际的键盘:

-(void)addGesturesToKeyboard{
    [self.keyboard.globeSwitch addTarget:self action:@selector(advanceToNextInputMode) forControlEvents:UIControlEventTouchUpInside];

    [self.keyboard.planA addTarget:self action:@selector(execPlanA) forControlEvents:UIControlEventTouchUpInside];
    // what I want to implement -> [self.keyboard.planA addTarget:self action:@selector(textFieldShouldReturn:) forControlEvents:UIControlEventTouchUpInside];

    [self.keyboard.planB addTarget:self action:@selector(execPlanB) forControlEvents:UIControlEventTouchUpInside];

    [self.keyboard.planC addTarget:self action:@selector(execPlanC) forControlEvents:UIControlEventTouchUpInside];
}

这是我的textFieldshouldReturn方法似乎不适用于我:

-(void)textFieldShouldReturn:(UITextField*)textField
{
     NSInteger nextTag = textField.tag + 1;
    // Try to find next responder
    UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
    if (nextResponder) {
        // Found next responder, so set it.
        [nextResponder becomeFirstResponder];
    } else {
        // Not found, so remove keyboard.
        [textField resignFirstResponder];
    }
}

enter image description here

0 个答案:

没有答案