当前位置 博文首页 > folder_xixi:IOS 将图片保存在 document/your

    folder_xixi:IOS 将图片保存在 document/your

    作者:[db:作者] 时间:2021-08-07 18:55

    将图片数据保存在 自定义的文件夹目录底下

    NSString *norPicPath = [self dataPath:[NSString stringWithFormat:@"%@.png",@"你的文件名字(例如:my.png)"]];
            NSLog(@"filepath: %@",norPicPath);
            
            BOOL norResult = [picData writeToFile:norPicPath atomically:YES];
            if (norResult) {
                [theDelegate refreshPageWithAction:@""];
            }else {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"图片保存不成功" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                [alert show];
            }
    ?
    
    
    <pre name="code" class="objc">- (NSString *)dataPath:(NSString *)file
    {
        
        NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"你想要自定的文件名字"];
        
        BOOL bo = [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
        NSString *result = [path stringByAppendingPathComponent:file];
        
        return result;
        
    }

     
    
    
    


    cs
    下一篇:没有了