Programmatically access image assets

后端 未结 3 1278
小鲜肉
小鲜肉 2020-12-06 23:22

My image assets catalog has a folder named \"Nature\" with hundreds of image files inside.

I would like to get an array of image file names under the \"Nature\" dire

3条回答
  •  庸人自扰
    2020-12-07 00:09

    I've searched this problem and get the conclusion that you could not access the IncludedStudyImages directory directly. Check these:

    Access Asset Catalog pathForResource
    Can I get a NSURL from an XCAssets bundle?

    Another way work around is that you could predefine the file name according to some order. For example names like "image1.png", "image2.png", "image3.png". And using this way you could do the selecting a random image feature.

提交回复
热议问题