一般collectionView 或者 tableview都有自帶的點(diǎn)擊函數(shù)撞鹉,如下:
1, collectionView
? ?-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
//一般情況,cell不是自定義UI
CollectionViewCell * cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
//即為要得到的cell//自定義的cell
TitleViewCell * cell = (TitleViewCell *)[self collectionView:collectionView cellForItemAtIndexPath:indexPath];
//即為要得到的cell
}
2,tableView
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{//非自定義cellUITableViewCell * cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
//自定義cellNewsTableViewCell * cell = (NewsTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
}