how to get keyboard location in ios 8 & add DONE button on numberPad

后端 未结 3 1107
花落未央
花落未央 2020-12-06 03:18

I am using below code to get the keyboard location from view & add DONE button on it.But in ios 8 it is not able to get keyboard location & hence not add DONE butto

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 03:57

    • I did like "Alex-stone" but I can't to click custom button.

    • My solution:

    //create DoneCustomReturnKeyButton to add into keyboard

     - (void)addDoneCustomReturnKeyButtonInKeyboard:(NSNotification *)notification
    {
    NSArray *arr = [[[[UIApplication sharedApplication] windows] lastObject] subviews];
    if (arr.count > 0) {
    
        UIView *keyboardView = [arr objectAtIndex:0];
        float height;
        if ([[keyboardView description] hasPrefix:@"

    }

    and create button.

     - (void)createDoneCustomReturnKeyButton
    {
        self.doneCustomReturnKeyButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.doneCustomReturnKeyButton setTitle:NSLocalizedString(@"NEXT", nil) forState:UIControlStateNormal];
        [self.doneCustomReturnKeyButton.titleLabel setFont:[UIFont systemFontOfSize:20]];
        self.doneCustomReturnKeyButton.adjustsImageWhenHighlighted = NO;
        self.doneCustomReturnKeyButton.backgroundColor = [UIColor lightGrayColor];
        [self.doneCustomReturnKeyButton setTintColor:[UIColor whiteColor]];
        [self.doneCustomReturnKeyButton addTarget:self
                                           action:@selector(doneCustomReturnKeyButtonAction:)
                                 forControlEvents:UIControlEventTouchUpInside];
    }
    

提交回复
热议问题