在iOS5中是否解决了没有完成按钮问题的UIKeyboardTypeNumberPad?

时间:2012-04-12 10:56:07

标签: iphone ipad ios5

我环顾四周,我不确定iOS 5中是否已解决此问题。我找到了这篇文章

return or done button in iOS 5

下面有一些代码,但我不知道我应该把它放在哪里?

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
    if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
        [keyboard addSubview:doneButton];
} else {
    if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
        [keyboard addSubview:doneButton];
}

1 个答案:

答案 0 :(得分:2)

首先为UIKeyboardDidShowNotification添加观察者,如下所示:

[[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(keyboardDidShow:) 
                                                 name:UIKeyboardDidShowNotification 
                                               object:nil]; 

并在keyboardDidShow中:编写此代码以添加完成按钮