且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Iphone:如何在图像视图中显示文档目录图像?

更新时间:2023-01-24 12:14:40

示例代码:

- (NSString *)applicationDocumentsDirectory {
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
}

-(void)loadimage{
    NSString *workSpacePath=[[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"your image-name"];
    UIImageView *myimage=[UIImageView alloc] initWithFrame:CGRectMake(0,0,20,20)];
    myimage.image=[UIImage imageWithData:[NSData dataWithContentsOfFile:workSpacePath]];    
    [self.view addSubView:myimage];
    [myimage release];
}

TNQ