ios - two custom cells in a UITableView -
i trying use 2 custom cells inside uitableview. problem running return not being called in right place. not sure need implement return stop control reaching end of non-void function.
here code inside cellforrowatindex.
static nsstring *kcellid = @"messagecell"; static nsstring *ucellid = @"unreadcell"; if (status == 0) { //static nsstring *kcellid = @"messagecell"; messagelistcell *cell = (messagelistcell *) [tableview dequeuereusablecellwithidentifier:kcellid]; if (priority == 0) { cell. imageviewimportance.image = nil; } if (priority == 1) { cell.imageviewimportance.image = [uiimage imagenamed:@"single exclamation.png"]; } if (priority == 2) { cell.imageviewimportance.image = [uiimage imagenamed:@"double exclamation mark.png"]; } if (priority == 3) { cell.imageviewimportance.image = [uiimage imagenamed:@"triple exclamation kmar.png"]; } //if (status == 0) //{ cell.backgroundcolor = [uicolor clearcolor]; cell.labelfrom.text = [nsstring stringwithformat:@"from: %@",m.from]; cell.labelfrom.font = [uifont boldsystemfontofsize:17]; cell.labelsubject.text = subject; cell.labelsubject.font = [uifont boldsystemfontofsize:17]; cell.labeltime.text = time; cell.labelto.text = [nsstring stringwithformat:@"to: %@",m.to]; cell.labelto.font = [uifont boldsystemfontofsize:17]; return cell; } else if (status != 0) { //static nsstring *ucellid = @"unreadcell"; messagelistcell *cell = (messagelistcell *)[tableview dequeuereusablecellwithidentifier:ucellid]; cell.backgroundcolor = [uicolor clearcolor]; cell.unreadlabelfrom.text = [nsstring stringwithformat:@"from: %@",m.from]; cell.unreadlabelsubject.text = subject; cell.unreadlabelto.text = [nsstring stringwithformat:@"to:%@",m.to]; cell.unreadlabeltime.text = time; return cell; } //nslog(@"description = %@",[cell description]); //return cell;
}
simply change else if
else
, compiler stop complaining.
the way have telling compiler check 2 condition, if none of them met? going returned?
you need else
block since else if
redundant else
need.
if (status == 0) { static nsstring *kcellid = @"messagecell"; messagelistcell *cell = (messagelistcell *) [tableview dequeuereusablecellwithidentifier:kcellid]; nsstring *imagename; switch (priority) { case 0: imagename = nil; break; case 1: imagename = @"single exclamation.png"; break; case 2: imagename = @"double exclamation mark.png"; break; case 3: imagename = @"triple exclamation kmar.png"; break; default: break; } cell.imageviewimportance.image = [uiimage imagenamed:imagename]; cell.backgroundcolor = [uicolor clearcolor]; cell.labelfrom.text = [nsstring stringwithformat:@"from: %@",m.from]; cell.labelfrom.font = [uifont boldsystemfontofsize:17]; cell.labelsubject.text = subject; cell.labelsubject.font = [uifont boldsystemfontofsize:17]; cell.labeltime.text = time; cell.labelto.text = [nsstring stringwithformat:@"to: %@",m.to]; cell.labelto.font = [uifont boldsystemfontofsize:17]; return cell; } else { static nsstring *ucellid = @"unreadcell"; messagelistcell *cell = (messagelistcell *)[tableview dequeuereusablecellwithidentifier:ucellid]; cell.backgroundcolor = [uicolor clearcolor]; cell.unreadlabelfrom.text = [nsstring stringwithformat:@"from: %@",m.from]; cell.unreadlabelsubject.text = subject; cell.unreadlabelto.text = [nsstring stringwithformat:@"to:%@",m.to]; cell.unreadlabeltime.text = time; return cell; }
Comments
Post a Comment