2012-04-12 32 views
1

我環顧四周,我不知道是否這個問題已經在iOS中5得到解決我發現這個職位未在iOS5中解決完成按鈕問題的UIKeyboardTypeNumberPad?

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]; 
} 

回答

2

首先對UIKeyboardDidShowNotification這樣添加觀察員:

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

和keyboardDidShow:寫這樣的代碼添加完成按鈕

+0

不要忘記刪除觀察者!它應該添加在viewWillAppear中並在viewWillDisappear中移除。如果您嘗試使用加載/卸載,您可以在其他屏幕堆疊在頂部時獲得一些片狀行爲。 – 2012-11-27 19:05:54

相關問題