![](/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.