我想在完成表演后滚动到UITableView的底部 [self.tableView reloadData]
我原本有
[self.tableView reloadData]
NSIndexPath* indexPath = [NSIndexPath indexPathForRow: ([self.tableView numberOfRowsInSection:([self.tableView numberOfSections]-1)]-1) inSection: ([self.tableView numberOfSections]-1)];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
Run Code Online (Sandbox Code Playgroud)
但后来我读了reloadData是异步的,所以滚动不因为发生self.tableView
,[self.tableView numberOfSections]
并且[self.tableView numberOfRowsinSection
都是0.
谢谢!
有什么奇怪的是我正在使用:
[self.tableView reloadData];
NSLog(@"Number of Sections %d", [self.tableView numberOfSections]);
NSLog(@"Number of Rows %d", [self.tableView numberOfRowsInSection:([self.tableView numberOfSections]-1)]-1);
Run Code Online (Sandbox Code Playgroud)
在控制台中它返回Sections = 1,Row = -1;
当我完成相同的NSLogs时,cellForRowAtIndexPath
我得到Sections = 1和Row = 8; (8是对的)
我UICollectionView
有一个UICollectionViewFlowLayout
,我想计算它的内容大小(intrinsicContentSize
通过AutoLayout调整其高度所需的返回).
问题是:即使我对所有单元都有一个固定且相等的高度,我也不知道我有多少"行"/行UICollectionView
.我也无法通过数据源中的项目数来确定计数,因为表示数据项的单元格的宽度不同,因此我在一行中的项目数量也不同UICollectionView
.
由于我在官方文档中找不到关于此主题的任何提示,谷歌搜索没有给我带来任何进一步的帮助和想法将非常感激.
每当完全加载UICollectionView时,我必须做一些操作,即那时应该调用所有UICollectionView的数据源/布局方法.我怎么知道?是否有任何委托方法来了解UICollectionView加载状态?
autolayout ×1
delegates ×1
height ×1
ios ×1
objective-c ×1
reload ×1
reloaddata ×1
uitableview ×1