简体   繁体   English

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

[英]asset catalog, images not loading on device, but fine in simulator

I have a three asset folders set up, one called Images which have the app icon and launch images in, one called Puzzles and one called ThumbPuzzle. 我设置了三个资源文件夹,一个名为Images,其中包含应用程序图标和启动图像,一个名为Puzzles,另一个名为ThumbPuzzle。

When testing on the simulator, the images all load fine, when testing on the device, the images don't load and the following error appears in the console. 在模拟器上进行测试时,图像都可以正常加载,在设备上进行测试时,图像不会加载,并且控制台中会出现以下错误。

mmap: Cannot allocate memory mmap:无法分配内存

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

I know the images are named correctly, since i copied their names from the catalog. 我知道图像命名正确,因为我从目录中复制了它们的名字。 I'm loading the images using the following 我正在使用以下内容加载图像

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

and the following in the pm_PuzzleCell 以及pm_PuzzleCell中的以下内容

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

Probably the xcassets is too big. 可能xcassets太大了。
Or better, the images in the xcassets are too big and xcode wan't load. 或者更好的是, xcassets中的图像太大而xcode xcassets加载。

mmap: Cannot allocate memory mmap:无法分配内存

I removed xcasset moving images in Resource folder and works well. 我删除了资源文件夹中的xcasset移动图像,效果很好。

The problem is avoided by importing the resources into the project, then importing them into the asset catalog. 通过将资源导入项目,然后将其导入资产目录,可以避免此问题。 Importing them straight into the catalog didn't work 将它们直接导入目录不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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