Ios 是,uitableview中未设置图像
我想运行一个代码,当代码为真时,应该显示正确的图像,当代码为假时,应该显示错误的符号。 牛肉干切碎成型时应显示正确的图像 数据应该从数据库中获取Ios 是,uitableview中未设置图像,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我想运行一个代码,当代码为真时,应该显示正确的图像,当代码为假时,应该显示错误的符号。 牛肉干切碎成型时应显示正确的图像 数据应该从数据库中获取 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cel
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (tableView == self.searchDisplayController.searchResultsTableView)
{
cell.textLabel.text = [searchResult objectAtIndex:indexPath.row];
int random = arc4random() % arrimg.count;
cell.imageView.image = [UIImage imageNamed:[arrimg objectAtIndex:random]];
cell.accessoryType = UITableViewCellAccessoryNone;
[cell.accessoryView setFrame:CGRectMake(0, 0, 15, 15)];
} else {
cell.textLabel.text = [arrname objectAtIndex:indexPath.row];
int random = arc4random() % arrimg.count;
cell.imageView.image = [UIImage imageNamed:[arrimg objectAtIndex:random]];
cell.accessoryType = UITableViewCellAccessoryNone;
// cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Yes_check.png"]];
// [cell.accessoryView setFrame:CGRectMake(0, 0, 15, 15)];
}
cell.backgroundColor = [UIColor colorWithRed:99.0/255 green:170.0/255 blue:229.0/255 alpha:1.0];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.font=[UIFont fontWithName:@"Marker Felt" size:15];
return cell;
}
请执行以下步骤:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if([checkmarkArray[indexPath.row] isEqualToString:@"NO"]) // Wrong image displayed here
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"wrongImage.png"]];
[cell.accessoryView setFrame:CGRectMake(0, 0, 15, 15)];
}
else
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"trueImage.png"]];
[cell.accessoryView setFrame:CGRectMake(0, 0, 15, 15)];
}
}
你目前的要求是什么?在Uitableview中,您需要显示两个图像,一个为真,另一个为假?答案不应只是代码。解释什么是错误的,需要什么修复。我想从数据库中获取数据