Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableview重新加载数据不是为iPhone 5重置帧_Ios_Uitableview_Reloaddata - Fatal编程技术网

Ios UITableview重新加载数据不是为iPhone 5重置帧

Ios UITableview重新加载数据不是为iPhone 5重置帧,ios,uitableview,reloaddata,Ios,Uitableview,Reloaddata,我正在使用pull-to-add函数向表视图添加新单元格。当下拉表格视图超过阈值时,将添加一个占位符单元格。然后,我调用reloadData并成为占位符单元格的第一响应者 问题是重新加载数据似乎并没有重置iPhone 5及更低版本的tableview框架。这会导致占位符单元格超出可见范围。表格偏移量应为0 添加占位符 编辑单元 iPhone5及更低版本 iphone6 查看本教程,完全按照您的需要操作: -(void)todoPlaceHolderAdded { NSLog(@"todo

我正在使用pull-to-add函数向表视图添加新单元格。当下拉表格视图超过阈值时,将添加一个占位符单元格。然后,我调用reloadData并成为占位符单元格的第一响应者

问题是重新加载数据似乎并没有重置iPhone 5及更低版本的tableview框架。这会导致占位符单元格超出可见范围。表格偏移量应为0

添加占位符

编辑单元

iPhone5及更低版本

iphone6


查看本教程,完全按照您的需要操作:
-(void)todoPlaceHolderAdded {
    NSLog(@"todoPlaceHolderAdded");

    // create the new item
    TodoItem *newItem = [[TodoItem alloc] initWithText:@""];
    [_todoList insertObject:newItem atIndex:0];

    // refresh the table
    [self.tableView reloadData];

    // find new cell
    ToDoCell* editCell;
    for (ToDoCell* cell in _tableView.visibleCells) {
        if (cell.todoItem == newItem) {
            editCell = cell;
            editCell.todoItem = newItem;
            _cellInEdit = cell;
            editCell.textField.placeholder = @"Enter task";
            break;
        }
    }

    // enter edit mode
    [editCell.textField becomeFirstResponder];

}
-(void)cellDidBeginEditing:(ToDoCell *)editingCell {
    NSLog(@"cellDidBeginEditing");
    _tableView.scrollEnabled = NO;
    _tableView.bounces = NO;
    _superViewHorizontalScroll.scrollEnabled = NO;
    _cellInEdit = editingCell;

    //Set offset to current editing cell
    _editingOffset = _tableView.contentOffset.y - editingCell.frame.origin.y;

    NSLog(@"Table Offset: %f", _tableView.contentOffset.y);
    NSLog(@"Frame y: %f", editingCell.frame.origin.y);
    NSLog(@"Offset: %f", _editingOffset);

    //Slide rows to editing cell
    for(ToDoCell* cell in [_tableView visibleCells]) {
        //Add flag for cells that edit is in progress
        cell.isEditing = YES;
        [UIView animateWithDuration:0.3
            animations:^{
                //Set new frame for cell
                cell.frame = CGRectOffset(cell.frame, 0, _editingOffset);

                //Reduce alpha for non editing cells
                if (cell != _cellInEdit) {
                    cell.alpha = 0.2;
                }
        }];
    }
}
2015-04-25 23:09:39.093 QuickScrollTest[7996:320879] todoPlaceHolderAdded
2015-04-25 23:09:39.093 QuickScrollTest[7996:320879] cellDidBeginEditing
2015-04-25 23:09:39.093 QuickScrollTest[7996:320879] Table Offset: -136.000000
2015-04-25 23:09:39.093 QuickScrollTest[7996:320879] Frame y: 0.000000
2015-04-25 23:09:39.093 QuickScrollTest[7996:320879] Offset: -136.000000
2015-04-25 23:11:01.071 QuickScrollTest[8179:323067] todoPlaceHolderAdded
2015-04-25 23:11:01.078 QuickScrollTest[8179:323067] cellDidBeginEditing
2015-04-25 23:11:01.078 QuickScrollTest[8179:323067] Table Offset: 0.000000
2015-04-25 23:11:01.078 QuickScrollTest[8179:323067] Frame y: 0.000000
2015-04-25 23:11:01.078 QuickScrollTest[8179:323067] Offset: 0.000000