自分のUICollectionViewをスクロールすると、いくつかのセルと時間にUILabelが表示されます。他のセルはセルに表示されますが、すべてではなく、どのように修正するのですか?あなたバグ:私のUILabelは単一のセルに表示され、修正する方法は?
ありがとうございました。このラベルは、同じラベルを他の細胞と混合
// cellForItemAtIndexPath
self.date = [NSDate dateWithTimeIntervalSince1970:[[searchResult objectForKey:@"drawDate"] intValue]];
self.dateFormatter = [[NSDateFormatter alloc] init];
[self.dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:[[NSLocale preferredLanguages] objectAtIndex:0]]];
[self.dateFormatter setDateStyle:NSDateFormatterShortStyle];
cell3.titleContest.hidden = YES;
cell3.titleContest.alpha = 0;
//self.dateContest.text = @"";
NSTimer *timer = [[NSTimer alloc] init];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateCounter:) userInfo:nil repeats:YES];
// countDownTimer
- (void)updateCounter:(NSTimer *)tmr
{
NSTimeInterval iv = [self.date timeIntervalSinceNow];
int d = iv/86400;
int h = (iv/3600) - (d * 24);
int m = (iv - (h + d * 24) * 3600)/60;
int s = lroundf(iv) % 60;
cell3.titleContest.text = [NSString stringWithFormat:@"%02d:%02d:%02d:%02d", d, h, m, s];
if (d + h + m + s <= 0
) {
[tmr invalidate];
}
[UIView animateWithDuration:0.5 animations:^{
cell3.titleContest.hidden = NO;
cell3.titleContest.alpha = 1;
} completion:^(BOOL finished) {
}];
}
を再利用して出ていき来るが、私はそれを置くために持っているコードにするために起因するリサイクルの細胞に発生しますカスタムセルで? –
リセット状態コード? 'cellForItemAtIndexPath'から直接呼び出すことも、' cellForItemAtIndexPath'から呼び出す関数の中でcustomCell.mの中に入れることもできます。 – Fonix
はい、リセットするコードは何ですか?分かりません –