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

标签 ios uiimageview 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;
}

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

最佳答案

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

关于ios - UIImage 显示在模拟器上,而不是在真实设备上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22027420/

相关文章:

ios - react native axios 请求在 IOS 模拟器中不起作用

ios - 更改所有 Collection View 单元格中的 View

iphone - 当服务器上的图像文件更改时,我的应用程序中的 SDWebImage 缓存图像会发生什么情况?

ios - 调整 UIImage 大小时内存泄漏

ios - 将 UIImageView 添加到 subview

ios - 如何同时使用 swift 2 和 swift 3?

ios - 如何使SVG在iOS上运行?

ios - 点击检测不适用于 UIImageView

iOS UIScrollView 抗锯齿

ios - UIImage 显示为不透明正方形(IOS Swift)