我正在使用tableView與自定義單元格。當我想使用navigationController的pushViewController函數顯示另一個視圖時,我循環訪問textfields並在其上調用resignFirstResponder。但resignFirstResponder只在顯示文本字段時才起作用,所以我首先滾動到頁面的頂部。這是代碼:tableView frame.origin問題後textField resignFirstResponder自定義tableViewCell
NSIndexPath *topIndexPath;
topIndexPath = [[NSIndexPath indexPathWithIndex:0] indexPathByAddingIndex:0];
[self.tableView scrollToRowAtIndexPath:topIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
[[self textFieldForRow:0] resignFirstResponder];
[[self textFieldForRow:1] resignFirstResponder];
[[self textFieldForRow:2] resignFirstResponder];
[[self textFieldForRow:3] resignFirstResponder];
這工作,但在這之後我的tableView有它的起源一些奇怪的問題。我試圖將它的超級本源設置爲0,但這沒有幫助。
這是問題的一個截圖:
正如你所看到的,我的tableview太大,到達底部時滾動條被卡在取景當中。
對不起,我的英語,我希望你能理解我,
提前感謝!
Hans
由於使用此方法,某人的應用已從應用商店中拒絕。如果你有興趣,它在這個線程中。 http://stackoverflow.com/questions/1823317/how-do-i-legally-get-the-current-first-responder-on-the-screen-on-an-iphone – 2010-02-05 16:42:19
非常感謝你:)改變了碼。 – HansPinckaers 2010-02-22 19:48:00