UIKeyboardTypeNumberPad without a done button

前端 未结 4 1321
执笔经年
执笔经年 2020-12-15 11:09

How can we implement UIKeyboardTypeNumberPad so that it will have a \'done\' button? By default it does not have one.

4条回答
  •  醉酒成梦
    2020-12-15 11:53

    If anybody had a problem that the DONE button keeps popping up when you try to load other types of keyboards in the same app, I know a lot of apps out there have this issue. Anyway, here is how I solved this: In your ViewController ( the same viewcontroller that you added DONE button ) add this code ( as is ) and it should solve your problems with DONE button keep reappearing. Hope it helps to some folks.

    - (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];   
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidHideNotification object:nil];
    
    } else {
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];  
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
    }
    

    }

提交回复
热议问题