2012-07-05 61 views
0

當用戶單擊輸入字段或選擇框並且本機iphone鍵盤可見時,我的佈局會中斷。我認爲這可能是一個好主意,如果你可以禁用滾動當本地鍵盤是可見的。 JavaScript能達到那個目標嗎?本機鍵盤在手機上可見時禁用滾動

在此先感謝

+0

我懷疑它的滾動導致你的問題。你可能沒有正確清理一些浮點數,但是如果沒有看到你的代碼,我們就無法開始解決你的問題。 – Lowkase 2012-07-05 16:22:37

+0

我沒有任何浮動元素。我並不在乎佈局是否中斷,只要用戶無法滾動即可看到它 – Viktor 2012-07-05 21:34:11

回答

0

您可以通過寄存器在viewDidLoad

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

[[NSNotificationCenter defaultCenter] addObserver: self 
             selector: @selector(keyboardWasHidden) 
              name: UIKeyboardDidHideNotification 
              object: nil]; 

recieving上UIKeyboardDidShowNotificationUIKeyboardDidHideNotification通知實現這一目標和實施選擇如下

當鍵盤約爲以顯示您將會收到此電話

- (void) keyboardWasShown 
{ 
    // Code to disable the scrolling of your scrollview 
} 

而且鍵盤時要隱藏你會得到一個來電來訪

- (void) keyboardWasHidden 
{ 
    // Code to enable the scrolling of your scrollview 
} 

高興,如果我能看到這有助於你在someways。快樂的一天。