UIImage显示在模拟器上,而不是在真实设备上



我已经尝试了其他类似标题的问题中的所有建议。我的情况似乎很特别。这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [tableView setSeparatorInset:UIEdgeInsetsZero];
    }
    NSString *cellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  if ([menu_List count] == 0){
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
      }
        NSString *newString = [[MainMenuArray objectAtIndex:indexPath.row] stringByReplacingOccurrencesOfString:@" " withString:@""];
          UIImage *image1 = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@", newString,@".png"]];
          UIImageView *imageView = [[UIImageView alloc] initWithImage:image1];
          [imageView setFrame:CGRectMake(5.0, 1.0, 41.0, 41.0)];
          [imageView setContentMode:UIViewContentModeScaleAspectFill];
          [cell addSubview:imageView];
          cell.textLabel.textColor = [UIColor whiteColor];
          GetData *GD = [[GetData alloc] init];
          cell.backgroundColor = [GD colorWithHexString:@"18204a"];
          cell.textLabel.text = [NSString stringWithFormat:@"%@", [MainMenuArray objectAtIndex:indexPath.row]];

    }else{
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
        cell.textLabel.text = [NSString stringWithFormat:@"%@", [menu_List objectAtIndex:indexPath.row]];
        cell.textLabel.textColor = [UIColor whiteColor];
        GetData *GD = [[GetData alloc] init];
        cell.backgroundColor = [GD colorWithHexString:@"18204a"];
    }
    return cell;
}

因此,字符串名称是正确的,并且与大小写匹配。我已经检查了我的构建设置,并且映像位于复制包资源中。所有这些都显示在模拟器中。七个中只有两个出现在列表中。如果我更改它们的显示顺序,它仍然是相同的两个图像显示。它们都出现在模拟器中。我正在使用ECSlidingViewController创建一个菜单,我希望图像显示出来。知道是什么原因造成的吗?

清理项目并检查大写字母。模拟器不区分大小写,但如果在代码上使用"myimage.png",但图像名称为 MyImage,则真实设备不会加载图像.png

确保为架构启用了 png

最新更新