Animation issue when deleting the last row of UITableView

后端 未结 5 875
傲寒
傲寒 2021-02-05 19:19

UPDATE: This is now fixed in iOS 8.0 and above. See my accepted answer for details.

I have an iOS 7 UITableView that I allow swipe-to-delete on rows. I\'m handling delet

5条回答
  •  庸人自扰
    2021-02-05 19:31

    You can also use the UITableView.tableFooterView property:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        ... 
    
        CGRect frame = [self.tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
        UIView *view = [[UIView alloc] initWithFrame:frame];
        view.backgroundColor = self.tableView.backgroundColor;
        self.tableView.tableFooterView = view;
    }
    

    This code goes into the view controller holding the UITableView.

    • Code assumes ARC.
    • It's a different story if you use background image for the table.
    • The code can be surrounded by "if (iOS > 7)" clause.

提交回复
热议问题