简体   繁体   中英

UIImage is showing on simulator, not on a real device

I have tried all of the suggestions in other similarly titled questions. My case seems to be special. Here's my code:

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

So the string name is correct, and it matches the case. I've checked my build settings, and the images are in copy bundle resources. All show up in the simulator. Only two of the seven appear in the list. If I change the order in which they appear, it is still the same two images that show up. They all show up in the simulator. I am using ECSlidingViewController to create a menu and I want the images to show up. Any idea on what could be causing it?

Clean your project and check for upper case letters. Simulator is not case sensitive, but real devices does not load an image if you use "myimage.png" on your code but your image name is MyImage.png

确保为架构启用了png

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM