【问题标题】:How to get List of Images Using NSBundle如何使用 NSBundle 获取图像列表
【发布时间】:2010-08-12 04:34:17
【问题描述】:

我的项目中有图像列表,我必须使用 NSBundle 获取整个列表,我该怎么做

谢谢

【问题讨论】:

    标签: iphone iphone-sdk-3.0


    【解决方案1】:

    应该这样做:

     NSLog(@"Images in bundle are:");
    
     NSString *imageExtension = @"png";
     NSArray *pngPaths = [[NSBundle mainBundle] pathsForResourcesOfType:imageExtension inDirectory:nil];
     for (NSString *filePath in pngPaths)
     {
         NSString *fileName = [filePath lastPathComponent];
         NSLog(@"%@", fileName);
     }
    

    只需将imageExtension 字符串更改为您想要的图像类型即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-11
      • 1970-01-01
      • 1970-01-01
      • 2011-05-01
      • 1970-01-01
      • 2021-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多