![](/img/trans.png)
[英]how can set different height or itemSize for each CollectionViewCell
[英]How to set different countdown timer to different labels of collectionviewcell in ios?
我正在一个应用程序上工作,我必须在事件中还剩几秒钟(所有事件都有所不同),然后我必须在每个collectionviewcell中打印事件的倒数时间(即剩余时间)。这里的行数是5假设吧。
- (col *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
static NSString *identifier = @"Cell";col *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
secondsLeft= seconds left depending on data which I can get successfully;
[self start];
cell.lbl_time.text=[NSString stringWithFormat:@"%02d:%02d:%02d", hours, minutes, seconds];
return cell;} -(void)updateCounter:(NSTimer *)theTimer{
if(secondsLeft > 0 ) {
secondsLeft -- ;
hours = secondsLeft / 3600;
minutes = (secondsLeft % 3600) / 60;
seconds = (secondsLeft %3600) % 60;
//count.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hours, minutes, seconds];
}
else
{
NSLog(@"Timer Invalidate");
// [timer invalidate];
}} -(void)start{
timer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateCounter:) userInfo:nil repeats:YES];}
让我知道我该怎么办。 提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.