#pragma mark - UICollectionViewDelegate
//添加按钮之前返回的是数据源的count
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
NSInteger count = self.mDataArray.count + 1;
return count;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == self.mDataArray.count)
{
//添加按钮对应的事件
...
}else{
//添加按钮之前对应的点击事件
...
}
}
#pragma mark - UICollectionViewDataSource
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
//自定义的addCell
if (indexPath.row == self.mDataArray.count)
{
AddCollectionViewCell *addCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"addCell" forIndexPath:indexPath];
[addCell cellForRowAtIndexPath:indexPath];
return addCell;
}
MSFriendCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MSFriendCollectionCell" forIndexPath:indexPath];
MSFriendData *friendData = self.mDataArray[indexPath.row];
[cell setCellData:friendData isShowNick:isShowNick indexPath:indexPath];
return cell;
}
网友评论