And*_*ers 4 cocoa-touch nsindexpath ios uicollectionview
我第一次使用UICollectionView.我正在尝试获取每个单元格的"行"值 - 用作单元格文本字段的标识符/标记.当cellForItemAtIndexPath被调用时,它看起来像[indexPath row];回归nil.当行为零时,如何获取单元格索引(或其他用作标识符的内容)?
注意 使用iOS7,如果这有任何区别......
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
// Returns nil
NSLog("Row: %d", indexPath.row);
}
Run Code Online (Sandbox Code Playgroud)
有什么想法/提示吗?
您不在集合视图中使用行的概念.您需要使用以下方法NSIndexPath:
+ (NSIndexPath *)indexPathForItem:(NSInteger)item inSection:(NSInteger)section;
Run Code Online (Sandbox Code Playgroud)
请注意row的属性NSIndexPath声明上UITableView.h,而item财产上的声明UICollectionView.h
| 归档时间: |
|
| 查看次数: |
7010 次 |
| 最近记录: |