- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个实现延迟加载的 UICollectionView,
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
[self loadImagesToVisiableCells];
}
效果不错。然而,问题是在任何滚动之前,前几个单元格显示占位符图像。因此,我尝试在检索要在下面的 UICollectionView 中显示的 json 文件的回调中调用 loadImagesToVisiableCells,
- (void)handleReceivedData: (NSArray*)results returnArrayOrDic:(NSNumber *)returnArrayOrDic{
NSLog(@"***************************");
NSLog(@"handleReceivedData has been called from PromotionViewController");
NSLog(@"jsonArray Length:%d",[results count]);
NSLog(@"jreturnArrayOrDic:%@",returnArrayOrDic);
if([returnArrayOrDic boolValue] == YES){
for(NSDictionary *dealDic in results) {
NSLog(@"dealDic: %@", dealDic);
//to populate the dealArray
Deal *deal = [[Deal alloc] initWithDict:dealDic];
[dealArray addObject:deal];
}
NSLog(@"%d deals have been populated to dealArray",[dealArray count]);
}else{
NSDictionary *jsonDictionary = (NSDictionary *)results;
for(id key in jsonDictionary) {
id value = [jsonDictionary objectForKey:key];
NSString *keyAsString = (NSString *)key;
NSString *valueAsString = (NSString *)value;
NSLog(@"key: %@", keyAsString);
NSLog(@"value: %@", valueAsString);
}
}
[self.collectionView reloadData];
[self loadImagesToVisiableCells];
}
调试消息显示在任何滚动之前,[[collectionView visibleCells] count] 返回 0。
- (void)loadImagesToVisiableCells{
NSLog(@"starting loadImagesToVisiableCells, visibleCells:%d",[[collectionView visibleCells] count]);
....
}
有什么想法吗?
问候锤子
最佳答案
感谢Reloading a UICollectionView using reloadData method returns immediately before reloading data
该问题是由于重载未完成引起的。解决方案是,
[collectionView reloadData];
**[self.collectionView layoutIfNeeded];**
[self loadImagesToVisiableCells];
关于ios - UICollectionView visibleCells 在滚动前返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26055626/
我遇到了一个问题,其中 CellIsInVisibleRange函数选择它不应该选择的单元格。 循环的代码如下: wCount = 0 loopCount = 0 For Each w
我正在使用 UITableViewController。 UITableView 显示 11 个自定义单元格。其中 10 个是动态的,1 个是静态的。 尽管如此计算行数: let cells = se
override func viewDidDisappear(_ animated: Bool) { tableView.visibleCells.forEach {
我正在尝试在 xcode 4.5 中使用自动化编写测试脚本。 我有一个 UICollectionView,我想点击一些当前不可见的单元格。 Per documentation ,我应该期望 cells
我正在尝试在初始加载时为表格 View 单元格设置动画。动画适用于所有单元格,除了表格底部的最后一个单元格拒绝动画。 这是因为 UITableView.visibleCells 最后没有返回这个单元格
我有许多自定义单元格对象(UITableViewCell 的子类),其中包含一些值,以允许用户在单个单元格(如步进器或其他东西)内进行交互。这些值存储在自定义单元格类中,因为调用 TableView
一个明显可见且全宽的内容 TableView 怎么会没有可见的单元格?为什么 tableview.visibleCells 为空? 最佳答案 我最好的猜测是,您在表格 View 有机会填充自身之前调用
目前我有包含 4 个单元格的 Collection View 。这是一个水平 collectionView,每个显示一个单元格,因此每次有一个单元格应该显示自己。当我旋转我的设备时,每个屏幕一个单元格
我有一个实现延迟加载的 UICollectionView, - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
NSArray * arrayOfVisibleTVC=[BNUtilitiesQuick ListController].tableViewA.visibleCells; NSLog(@"array
当单元格进出设备屏幕时,我希望我的 viewController 准确知道什么进来了,什么出去了。有办法做到这一点吗? 最佳答案 没有专门针对“可见单元格”的委托(delegate)方法。当单元格离开
我有一个 tableView。我使用 CADisplayLink 调用一些滚动 tableView 的代码。我这样做是因为我想自定义滚动所需的时间,而不是使用 UITableView 方法。 我想要一
在 Collection View 中,我想知道 Collection View 中显示的第一项。我想我会查看 visibleCells 并将成为列表中的第一项,但事实并非如此。 最佳答案 针对 Sw
我想知道 UICollectionView 的 visibleCells 属性的计数何时更改。我知道我可以观察继承自 NSObject 的对象,只要我想观察的属性是 dynamic。例如: let v
我创建了一个custom UITableViewCell包含一个collectionView。此自定义单元格符合 UICollectionViewDelegate 和 UICollectionView
当我打印可见单元格时,它会显示两种类型的单元格,请参见下文po cells ▿ 2 elements - 0 : > ▿ 1 : > 但是当我尝试获取单元格对象时,它返回 false (lldb) p
我想对可见单元格进行更改,以便它们反射(reflect)对基础业务对象(数组中的对象,与表中单元格的索引和数组中的对象相关)所做的更改。 我只需要找出表中单元格的索引或indexPath。因此,如果有
我正在使用间隔为 1.1 秒的 NSTimer,计时器正确触发,但(大部分)在滚动 UITableView.visibleCells 时不更新响应,响应包含不可见的单元格。 下面是我的 Swift 代
我有一个自定义的 UICollectionView 并且单元格加载到 cellForItemAt 中但是当我尝试使用 visibleCells 获取所有可见单元格时我没有获取所有单元格. 例如,在 c
我的 Collection View 就像上面一样,当选定的单元格全部消失时我正在调用一个 Action : - (IBAction)clearAction:(UIButton *)sender {
我是一名优秀的程序员,十分优秀!