具有自动布局功能的故事板
self.couponTableViewHeightConstraint.const = [self.coupons count] * cellHeight;
[self.couponTableView scrollToRowAtIndexPath:selectedIndexPath
atScrollPosition:UITableViewScrollPositionNone
animated:NO];
不行!
因为更改污点不能更改表视图的框架!
应该像这样使用 contentOffset :
self.couponTableView.contentOffset = CGPointMake(0, (int)currentIndex * cellHeight);
如果您
正在使用scrollToRowAtIndexPath:selectedIndexPath
请确保不要在viewdidload
或viewwillappear
中使用它。否则,您将在呈现uitableview
之前调用该方法。
请改用viewDidLayoutSubviews
。