2014-02-25 38 views
0

我尝试了其他类似题目中的所有建议。我的情况似乎很特殊。这里是我的代码: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创建一个菜单,我希望图像显示出来。任何想法是什么可能导致它?

+0

删除启用图片重新添加它....它为我工作 – logixologist

+0

清理您的项目,然后重新在设备上运行。如果您添加资源,则必须为每个要添加的新设备执行清理/重建。愚蠢的,我知道。 – Putz1103

+0

你确定你的图片已添加到包中吗? – ignotusverum

回答

2

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

0

确保您的PNG是架构

相关问题