-2
我的代码目前能够更改我拥有的标签背景。标签从服务器更新并可能不一致地返回标签,而是作为一个句子而不是一个单词。有没有办法将if(@"%@",[cell.lblStatus.text isEqual: @"Full"])
更改为标签包含单词的地方?如果'contains'代替isEqual,有没有办法使用?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
MartaViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
Object *currentHotel = [self.objectHolderArray
objectAtIndex:indexPath.row];
cell.lblStation.text = currentHotel.station;
cell.lblStatus.text = currentHotel.status;
NSLog(@"%@", cell.lblStatus.text);
if(@"%@",[cell.lblStatus.text isEqual: @"Full"])
cell.lblStatus.backgroundColor = [UIColor redColor];
else
cell.lblStatus.backgroundColor = [UIColor greenColor];
return cell;
}