2017-04-18 13 views
-2

私のコードでは、現在持っているラベルの背景を変更することができます。ラベルはサーバーから更新され、ラベルが矛盾して1つの単語の代わりに文として返されることがあります。 if(@"%@",[cell.lblStatus.text isEqual: @"Full"])をラベルに単語が含まれている場合に変更する方法はありますか?isEqualの代わりに 'contains'を使用する方法はありますか?

- (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; 
} 

答えて

0

・ホープ、このヘルプあなた

if ([cell.lblStatus.text rangeOfString:@"Full"].location != NSNotFound) { 
    NSLog(@"Contain"); 
    cell.lblStatus.backgroundColor = [UIColor redColor]; 
} else { 
    NSLog(@"No Contain"); 
    cell.lblStatus.backgroundColor = [UIColor greenColor]; 
} 
関連する問題