InsertRowsAtIndexPaths,在[_mainTableView endUpdates]中断,但如果我删除beginupdates和endUpdates,将在SDAutoLayout中断

时间:2017-10-11 02:56:38

标签: ios insert tableview

[UIView animateWithDuration:0.2f动画:^ {

    NSMutableArray *indexPaths = [[NSMutableArray alloc] init] ;
    [_dataArray addObject:@"loading"];
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    [indexPaths addObject: indexPath];
    [_mainTableView beginUpdates];
    [_mainTableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
    [_mainTableView endUpdates];

} completion:^(BOOL finished) {
  //  [_mainTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:_dataArray.count - 1 inSection:0] atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}];

pragma mark -UITableViewDelegate,UITableViewDataSource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
 }

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
 (NSInteger)section
 {
  return _dataArray.count;
 }

0 个答案:

没有答案