我正在UITableViewCell
中使用UICollectionView
。我完成了添加內容,我可以看到內部UITableViewCell
。在UITableViewCell中檢測UICollectionView上的點擊
但是現在我不知道如何檢查哪個cell
的UICollectionView
是在UITableView
的哪一行裏面被點擊的。
所以,如果有人知道如何識別它會有幫助。
在此先感謝。
#pragma mark
#pragma mark - UITableViewDelegate and UITableViewDatasource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 15;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
CellForCollectionView *cell = [tableView dequeueReusableCellWithIdentifier:@"CellForCollectionView"];
if (cell == nil) {
cell = [[CellForCollectionView alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CellForCollectionView"];
}
cell.categoryCollectionView.delegate = self;
cell.categoryCollectionView.dataSource = self;
[cell.categoryCollectionView registerNib:[UINib nibWithNibName:@"CollectionCellForCategory" bundle:nil] forCellWithReuseIdentifier:@"CollectionCellForCategory"];
cell.lblCategoryName.text = [NSString stringWithFormat:@" Category %d",indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
#pragma mark
#pragma mark - UIcollectionViewDelegate and UIcollectionViewDatasource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 15;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
CollectionCellForCategory *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCellForCategory" forIndexPath:indexPath];
cell.imagCategory.layer.borderColor = [[UIColor blackColor]CGColor];
cell.imagCategory.layer.borderWidth = 1.0f;
return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"%ld",(long)indexPath.row);
NSLog(@"%ld",(long)indexPath.section);
}
選擇不適用於收集視圖嗎? – Himanshu
是否選擇正在工作,但使用此如何才能識別UITableView的行號。 –
你可以給我你的用戶界面的想法。 – Himanshu