gpt4 book ai didi

ios - 如何在数组中有多个图像路径?

转载 作者:行者123 更新时间:2023-11-29 02:30:03 25 4
gpt4 key购买 nike

我需要同时显示 .png 和 .jpg,但不确定如何同时显示。下面的代码有效:

NSArray *imagePaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:@"CarSeats"];

但这不是:

NSArray *imagePaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"png, jpg" inDirectory:@"CarSeats"];

最佳答案

分别获取PNG和JPG路径,然后组合数组:

NSArray *pngPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"png"
inDirectory:@"CarSeats"];
NSArray *jpgPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg"
inDirectory:@"CarSeats"];
NSArray *imagePaths = [pngPaths arrayByAddingObjectsFromArray:jpgPaths];

关于ios - 如何在数组中有多个图像路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27021385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com