Table View scroll when text field begin editing iphone

前端 未结 3 1473
-上瘾入骨i
-上瘾入骨i 2021-01-17 04:51

I have table view controller in iphone application. Table view has two sections. First section has two rows and second section has one row. Second section has a custom table

相关标签:
3条回答
  • 2021-01-17 05:20

    I have run into this on Static Cell TVC's. There is an issue when overriding viewWillAppear and NOT calling its Super. So if you are doing that, make sure to call

    [super viewWillAppear:animated];
    

    at the top of viewWillAppear

    0 讨论(0)
  • 2021-01-17 05:34

    My problem was I was adding the table cell containing the UITextField in the

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

    function. If you do this the automatic UITableView scrolling doesn't work.

    So, you have to do some arithmetic to work out when your last row is showing and put your special UITableViewCell in here along with all the others.

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    0 讨论(0)
  • 2021-01-17 05:44

    You want to use the setContentOffset method of the table view. Determine the magnitude of the vertical scroll (in pixels), and then:

    CGFloat verticalScroll = ... your code here ...
    [self.tableView setContentOffset:CGPointMake(0, verticalScroll) animated:YES];
    
    0 讨论(0)
提交回复
热议问题