2012-11-26 75 views
2

如果用戶點擊最後一個單元格的tableview中沒有滾動UITableView的頁腳

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection: (NSInteger)section{ 


      UIView *view =[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; 
      [view setBackgroundColor:[UIColor blackColor]]; 
      return view; 
} 

如果是分段表這個作品的文本字段我已經添加在普通樣式頁腳到UITableView,請幫助

+0

你確切想要什麼?以及你面臨的問題? –

+0

我只是想滾動tableview如果tableviewcell中的textfield被鍵盤隱藏,因此我添加了tableview的頁腳,這個功能的作品,如果它是一個簡單的TableView的分段tableview它不工作 –

回答

0
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { 
    if(textField == yourTextField){ /// here write name of your Textfield in which you want to scroll tableview 
     [UIView beginAnimations:nil context:nil]; 
     [UIView setAnimationDuration:0.3]; 
     yourTableView.frame = CGRectMake(yourTableView.frame.origin.x, -160, yourTableView.frame.size.width, tblContactUS.frame.size.height); 
     [UIView commitAnimations]; 
    } 
    return YES; 
} 

,並把你的TableView與前一幀,然後用波紋管方法

- (BOOL)textFieldShouldReturn:(UITextField *)textField 
{ 
    [textField resignFirstResponder]; 
    if(textField == yourTextField){ /// here write name of your Textfield in which you want to scroll down tableview 
      [UIView beginAnimations:nil context:nil]; 
      [UIView setAnimationDuration:0.3]; 
      yourTableView.frame = CGRectMake(yourTableView.frame.origin.x, 0, yourTableView.frame.size.width, tblContactUS.frame.size.height); 
      [UIView commitAnimations]; 
    } 
    return YES; 
} 

我希望這可以幫助你...

+0

謝謝這個作品,解決了我的問題,但我不知道爲什麼在普通風格的uitableview中添加頁腳沒有滾動頂部我也添加了下面的代碼[self.detailTableView scrollToRowAtIndexPath:[self.detailTableView indexPathForCell:cell] atScrollPosition:UITableViewScrollPositionTop animated:YES];但仍然無法正常工作 –

+0

@lochana我不確定隊友,但它的問題與其中組的部分移動到表的第一部分,當它在組風格和簡單的這裏這個方法沒有找到表中的部分,因爲它的風格是純所以我認爲這對這個問題的共鳴... –

+0

謝謝你,我會堅持你的答案爲簡單的tableview –