How to get path of image form Resource of main bundle

前端 未结 3 921
谎友^
谎友^ 2021-01-02 14:04

i have an iPhone application in which i added images directory (Group) in to Resources (group). i want to access that images which is in imag

3条回答
  •  心在旅途
    2021-01-02 14:37

    for soultion....

    Go to : Target -> "Build Phases" -> "copy bundle Resources" Then add that particular file here.

    clean the project and RUN. It works.

    and also see...

    NSBundle pathForResource inDirectory gives nil

    and also check...

    NSString *path = [[NSBundle mainBundle] resourcePath];
    NSFileManager *fm = [NSFileManager defaultManager];
    NSError *error = [[NSError alloc] init];
    NSArray *directoryAndFileNames = [fm contentsOfDirectoryAtPath:path error:&error];
    

    print all value of this directoryAndFileNames and check your filename is exist in that or not....

提交回复
热议问题