Uitableview ScrollToRowatineXpath:atScrollPosition:在自动布局中不工作
具有自动布局的故事板Uitableview ScrollToRowatineXpath:atScrollPosition:在自动布局中不工作,uitableview,storyboard,autolayout,uistoryboard,Uitableview,Storyboard,Autolayout,Uistoryboard,具有自动布局的故事板 self.couponTableViewHeightConstraint.const = [self.coupons count] * cellHeight; [self.couponTableView scrollToRowAtIndexPath:selectedIndexPath atScrollPosition:UITableViewScrollPositionNone
self.couponTableViewHeightConstraint.const = [self.coupons count] * cellHeight;
[self.couponTableView scrollToRowAtIndexPath:selectedIndexPath
atScrollPosition:UITableViewScrollPositionNone
animated:NO];
不行 因为更改约束无法更改tableview的框架 应该像这样使用contentOffset:
self.couponTableView.contentOffset = CGPointMake(0, (int)currentIndex * cellHeight);
如果您使用的是
ScrollToRowatinexPath:selectedIndexPath
请确保您没有在viewdidload
或视图中使用它。否则,您将在呈现uitableview
之前调用该方法
在viewdilayoutsubview
中使用它