這是一個紅包倒計時的dmeo,是我的一個同事問我的一個問題,廢了很長時間我用collectionview去實現,我當時寫的時候有一個問題卡住了,就是怎麼讓一個紅包消失後從新把紅包的排列重新進行。
最後,我師傅給我一個方式解決很好,分享出來大家看一下。
github地址
中心代碼:
- (void)deleCell:(NSNotification *)user{
if (self.myArray.count) {
// 使用時打開註釋,注意:關閉方法一
NSDictionary *dic = user.userInfo;
MyCell *cell = (MyCell *)dic[@"myCell"];
NSInteger index1 = [self.myArray indexOfObject:self.myArray1[cell.tag]];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index1 inSection:0];
[self.myArray removeObject:self.myArray1[cell.tag]];
[_collectionView deleteItemsAtIndexPaths:@[indexPath]];
}else{
NSLog(@"self.myArray is nil");
}
}
運行結果: