PhotoViewController + MockPhotoSource (display local photos)
-
21-09-2019 - |
Question
If someone have ever use the PhotoViewController and so the MockPhotoSource in the three20 open source project can he told me how can I change the code to display photo store locally and not in the internet. This is an example of the code to display one photo:
- (void)viewDidLoad {
self.photoSource = [[MockPhotoSource alloc]
initWithType:MockPhotoSourceNormal
title:@"Flickr Photos"
photos:[[NSArray alloc] initWithObjects:
[[[MockPhoto alloc]
initWithURL:@"http://farm4.static.flickr.com/3246/2957580101_33c799fc09_o.jpg"
smallURL:@"http://farm4.static.flickr.com/3246/2957580101_d63ef56b15_t.jpg"
size:CGSizeMake(960, 1280)] autorelease], nil]
];
}
@end
The method look like that:
- (id)initWithURL:(NSString )URL smallURL:(NSString)smallURL size:(CGSize)size
caption:(NSString*)caption {
if (self = [super init]) {
_photoSource = nil;
_URL = [URL copy];
_smallURL = [smallURL copy];
_thumbURL = [smallURL copy];
_size = size;
_caption = [caption copy];
_index = NSIntegerMax;
}
return self;
}
I'm not an expert in objective-C and there is not enough help for this project for the moment I think.
Best Regards,
Solution
Ok I find a solution, it was not complicated I just need to use the bundle path just after initWithURL and smallURL like that:
initWithURL:(@"bundle://image.jpg")
smallURL:(@"bundle://smallimage.jpg")
Of course after I will use a database to display the path so I will put an argument after bundle I think its '%s'
OTHER TIPS
URL is not only for the resource on the internet, there's a file URL. Typically, you generate a file URL in Cocoa as in
NSString* path= some path in the file system ;
NSURL* fileURL=[NSURL fileURLWithPath:path];
Then you can use the fileURL as you want!