Roh*_*wal 3 iphone ios uicollectionview uicollectionviewcell
我想知道如何设置我的UICollectionView每个部分最多可以选择1个单元格.我看到有allowsMultipleSelectionUICollectionView 的属性,但我想知道如何防止在同一部分中选择多个单元格.
我是否需要在– collectionView:shouldSelectItemAtIndexPath:和collectionView:shouldDeselectItemAtIndexPath:方法中实现逻辑或者是否有更简单的方法?
谢谢!
Pab*_*blo 10
在你的didSelectRowAtIndexPath中,你可以这样做:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
NSArray * selectedRows = self.tableView.indexPathsForSelectedRows;
for (NSIndexPath * selectedRow in selectedRows) {
if ((selectedRow.section == indexPath.section) && (selectedRow.row != indexPath.row)) {
[self.tableView deselectRowAtIndexPath:selectedRow animated:NO];
}
}
}
Run Code Online (Sandbox Code Playgroud)
allowsMultipleSelection应设置为YES.
希望能帮助到你!
| 归档时间: |
|
| 查看次数: |
4102 次 |
| 最近记录: |