2
我想實現代碼,以推動向上滾動,如果隱藏在鍵盤下。 代碼中的第一部分,它說:「在你的視圖控制器的某處調用此方法」應該在視圖中加載的地方在哪裏?我應該寫 [self.registerForKeyboardNotifications}; ??請幫忙。我應該在視圖控制器中調用方法?
// Call this method somewhere in your view controller setup code.
- (void)registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
}
並刪除我簡單寫入:registerForKeyboardNotifications =零; 對不對? – Shinnawy 2010-12-16 00:11:45
你可能想要寫一個resignFromKeyboardNotifications方法,並在該調用中[[NSNotificationCenter defaultCenter] removeObserver:self name:*將通知名稱放在這裏* object:nil] – MCannon 2010-12-16 00:18:36