我有一個包含25個單元格的集合視圖對於一個單元格,我將文本顏色創建爲白色。現在,當我重新加載集合視圖時,其他單元格的文本顏色也會在我重新加載集合視圖時逐漸變爲白色。我不知道問題在哪裏。這是我的代碼。收集視圖中的奇怪行爲
if (indexPath.item == 0)
{
myCell.hidden=NO;
NSLog(@"index path = %ld",(long)indexPath.row);
NSArray *Object= [[jsonData valueForKey:@"TimeTabledPeriods"]objectAtIndex:0];
NSLog(@"object %@",Object);
myCell.roomLabel.text= [NSString stringWithFormat:@"Room: %@", [Object valueForKey:@"RoomDescription"]];
myCell.subjectLabel.text = [Object valueForKey:@"SubjectDescription"];
[myCell.redXbuttonOutlet setTag:indexPath.row];
[myCell.redXbuttonOutlet addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
myCell.noSessionView.backgroundColor=[UIColor clearColor];
myCell.myLearningChoicesBackground.hidden=YES;
if ([[Object valueForKey:@"Changed"] isEqualToString:@"YES"])
{
if ([[Object valueForKey:@"ChangedColorCode"] isEqualToString:@"Present"])
{
myCell.noSessionView.backgroundColor=[UIColor colorWithRed:97.0/255.0 green:182.0/255.0 blue:73/255.0 alpha:1];
//The below lines to change the text color to white is written only for index path 0
myCell.roomLabel.textColor=[UIColor whiteColor];
myCell.subjectLabel.textColor=[UIColor whiteColor];
}
}
//code for other cells
if (indexPath.item == 1)
{
myCell.hidden=NO;
NSLog(@"index path = %ld",(long)indexPath.row);
NSArray *Object= [[jsonData valueForKey:@"TimeTabledPeriods"]objectAtIndex:0];
NSLog(@"object %@",Object);
myCell.roomLabel.text= [NSString stringWithFormat:@"Room: %@", [Object valueForKey:@"RoomDescription"]];
myCell.subjectLabel.text = [Object valueForKey:@"SubjectDescription"];
[myCell.redXbuttonOutlet setTag:indexPath.row];
[myCell.redXbuttonOutlet addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
myCell.noSessionView.backgroundColor=[UIColor clearColor];
myCell.myLearningChoicesBackground.hidden=YES;
if ([[Object valueForKey:@"Changed"] isEqualToString:@"YES"])
{
if ([[Object valueForKey:@"ChangedColorCode"] isEqualToString:@"Present"])
{
myCell.noSessionView.backgroundColor=[UIColor colorWithRed:97.0/255.0 green:182.0/255.0 blue:73/255.0 alpha:1];
}
}
if (indexPath.item == 3)
{
myCell.hidden=NO;
NSLog(@"index path = %ld",(long)indexPath.row);
NSArray *Object= [[jsonData valueForKey:@"TimeTabledPeriods"]objectAtIndex:0];
NSLog(@"object %@",Object);
myCell.roomLabel.text= [NSString stringWithFormat:@"Room: %@", [Object valueForKey:@"RoomDescription"]];
myCell.subjectLabel.text = [Object valueForKey:@"SubjectDescription"];
[myCell.redXbuttonOutlet setTag:indexPath.row];
[myCell.redXbuttonOutlet addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
myCell.noSessionView.backgroundColor=[UIColor clearColor];
myCell.myLearningChoicesBackground.hidden=YES;
if ([[Object valueForKey:@"Changed"] isEqualToString:@"YES"])
{
if ([[Object valueForKey:@"ChangedColorCode"] isEqualToString:@"Present"])
{
myCell.noSessionView.backgroundColor=[UIColor colorWithRed:97.0/255.0 green:182.0/255.0 blue:73/255.0 alpha:1];
}
}
//等 }
現在,這是的tableView或的CollectionView – EridB 2014-10-08 13:42:01
colelction視圖 – iOSDeveloper 2014-10-08 13:47:36
你可以添加其他單元的代碼嗎? – hoya21 2014-10-08 13:47:36