2011-04-28 10 views
4

我正在尋找一種方法來添加一個按鈕到一個鍵盤的配件視圖,當觸摸輸入字段時出現的一個按鈕到一個UIWebView,而不使用一些私人功能或一些有問題的技巧。iPhone - 添加一個按鈕到鍵盤現有的配件視圖(從UIWebView鍵盤)

enter image description here

你知道我怎麼可以這樣做呢?

注:我知道我可能會捕捉鍵盤顯示/隱藏事件。我要求的是如何添加按鈕。

+0

嗨看看下面的鏈接http://gabriel-tips.blogspot.com/2011/05/input-accessory-view-how-to-add-extra.html – karthick 2011-11-13 15:06:01

回答

1

你可以做到這一點使用UIKeyboardWillShowNotification直視UIWindow reference有關它的信息:當甚至一個文本框一個UIWebView選擇

[[NSNotificationCenter defaultCenter] 
addObserver:self selector:@selector(keyboardWillShow:) 
name:UIKeyboardWillShowNotification object:nil]; 

該通知提出。

看蘋果KeyboardAccessory示例代碼顯示瞭如何做到這一點。該示例代碼使用UITextXxxx inputAccessoryView屬性,我懷疑你可以使用它。但通知會給你足夠的信息來添加附件直接在您的看法,甚至在上面的UIWindow,而且即使使用鍵盤製作動畫:

(gdb) po notification 
NSConcreteNotification 0xb5a2190 {name = UIKeyboardWillShowNotification; userInfo = { 
    UIKeyboardAnimationCurveUserInfoKey = 0; 
    UIKeyboardAnimationDurationUserInfoKey = "0.300000011920929"; 
    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 260}}"; 
    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 610}"; 
    UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 350}"; 
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 480}, {320, 260}}"; 
    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 220}, {320, 260}}"; 
}} 
0

的UIKit允許應用程序來代替自定義輸入意見的體制鍵盤。它還使應用程序能夠在系統鍵盤或自定義輸入視圖上方顯示附件視圖。此外,它使應用程序能夠在用戶點擊輸入視圖或輸入附件視圖的控件時播放按鍵聲音。

參考here更多

0

this apple example看看,因爲它要搜索什麼的。但總的來說,這個想法是取代UIWebView的inputAccessoryView以顯示您的自定義視圖。