资产目录,图像未在设备上加载,但在模拟器中很好

时间:2013-10-08 18:51:03

标签: ios ios7 xcode5 asset-catalog

我设置了三个资源文件夹,一个名为Images,其中包含应用程序图标和启动图像,一个名为Puzzles,一个名为ThumbPuzzle。

在模拟器上进行测试时,图像都可以正常加载,在设备上进行测试时,图像不会加载,并且控制台中会出现以下错误。

  

mmap:无法分配内存

     

错误:CUICommonAssetStorage -initWithPath:在/ var / mobile / Applications / 6DF65069-9ED2-4EE8-966A-5B63CBF36136 / Puzzle中找不到存储文件   Mania.app/Assets.car

我知道图片的名称是正确的,因为我从目录中复制了他们的名字。我正在使用以下

加载图像
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    pm_PuzzleCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    PM_Puzzle *puzzle = [self.frcPuzzles objectAtIndexPath:indexPath];
    cell.puzzle = puzzle;
    return cell;
}

以及pm_PuzzleCell中的以下内容

-(void) setPuzzle:(PM_Puzzle *)puzzle
{
    if(_puzzle != puzzle) {
        _puzzle = puzzle;
    }
    [self.imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"Thumb%@", [puzzle puzzleImage]]]];
}

2 个答案:

答案 0 :(得分:1)

xcassets可能太大了 或者更好的是,xcassets中的图像太大而xcode不会加载。

  

mmap:无法分配内存

我删除了资源文件夹中的xcasset个移动图片,效果很好。

答案 1 :(得分:0)

通过将资源导入项目,然后将其导入资产目录,可以避免此问题。将它们直接导入目录不起作用

相关问题