2

UITableView如果用户单击表格视图未滚动的最后一个单元格的文本字段,我已在普通样式中添加页脚

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


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

如果它是一个有效的分段表,请帮助

4

1 回答 1

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;
}

我希望这可以帮助你...

于 2012-11-26T07:08:35.963 回答