iOS UItableview scrollToRowAtIndexPath not working anymore

前端 未结 9 624
不知归路
不知归路 2020-12-30 01:14

This morning I just installed new Xcode which includes iOS 6.

I have a table view loaded with a plist file containing chapters and lines. Chapters define the section

9条回答
  •  太阳男子
    2020-12-30 02:03

    Objective-C

    [self.tableView reloadData];
    dispatch_async(dispatch_get_main_queue(), ^{
            NSIndexPath *rowIndexPath = [NSIndexPath indexPathForRow:3 inSection:0];
            [self.tableView scrollToRowAtIndexPath:rowIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
    });
    

    Swift

    tableView.reloadData()
    DispatchQueue.main.async {
        let indexPath = IndexPath(row: linePos, section: chapterPos)
        self.tableView.scrollToRow(at: indexPath, at: .top, animated: true)
    }
    

提交回复
热议问题