【发布时间】:2016-10-06 06:46:48
【问题描述】:
我有如附图所示的用户界面。它有两个组件,主要是 UICollectionView 和 UITableView。
当用户从 UITableView 中选择任何单元格时,我想在这里实现什么,我想更新 Top CollectionViewCell。
到目前为止我做了什么。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(![self.selectedIndexPath isEqual:indexPath]){
UITableViewCell* uncheckCell = [tableView cellForRowAtIndexPath:self.selectedIndexPath];
uncheckCell.accessoryType = UITableViewCellAccessoryNone;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
UITableViewCell* cellCheck = [tableView cellForRowAtIndexPath:indexPath];
cellCheck.accessoryType = UITableViewCellAccessoryCheckmark;
self.selectedIndexPath = indexPath;
NSIndexPath *collectionIndex = [NSIndexPath indexPathForItem:0 inSection:self.currentPage];
//TODO:Find Correct Cell
UICollectionViewCell *cellToUpdate = [self.collectionView cellForItemAtIndexPath:collectionIndex];
for (UIView *subView in [cellToUpdate.contentView subviews]) {
if ([subView isKindOfClass:[CustomView class]]) {
CustomView *infoView = (CustomView *)subView;
[infoView updateInfoWithIndex:indexPath.row];
}
}
[self.collectionView reloadData];
}
我认为我在下面的行中做错了。不确定是什么?
NSIndexPath *collectionIndex = [NSIndexPath indexPathForItem:0 inSection:self.currentPage];
【问题讨论】:
-
使用代理伙伴。
标签: ios objective-c uicollectionview uicollectionviewcell nsindexpath