Inverted images in the simulator - objective-c

I have a bit of simple code, that pulls images from the documents directory.. and loads it into an imageView.
- (void)viewDidLoad
{
[super viewDidLoad];
NSString* pathToFile = [NSString stringWithFormat:#"%#/images/%#",[self documentsDirectory],#"copy.jpg"];
UIImageView *tmp = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:pathToFile]];
[self.view addSubview:tmp];
}
- (NSString *)documentsDirectory
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [paths objectAtIndex:0];
}
My image, when viewed shows up correct, but when it's loaded into the app and viewed on the simulator.. it's inverted.
Example: https://skitch.com/critz/fnh8p/colorsnapper
any ideas, suggestions.. would be /greatly/ appreciated..

Interesting... Same code base run in >4.2 and the images are inverted. If I run it in the 5bx simulator.. they come out as they should.. SMH. Oh well..

Related

Downloading From Parse on Apple TV

The bounty expires in 3 days. Answers to this question are eligible for a +500 reputation bounty.
user717452 wants to draw more attention to this question.
I have a parse server set up, and as part of it, small PDFs (425KB) are stored on it. I need my Apple TV to be able to display these, but since they change often, it has to come from Parse server, and not just the main bundle where I update it with each update of the app. The issue I'm running into is the lack of an NSDocumentsDirectory on the Apple TV. How do y'all handle this? I've been using the Cache directory, but it seems to only work half the time with the code I am currently using. If I run it at launch from AppDelegate, by the time the PDF is needed, it may not be there, and if I have it set to run this code right when I need it, there is a delay, and sometimes, it simply doesn't show up. Would using NSTemporaryDirectory() be better? UPDATE, no, it doesn't. Works fine on simulator, on Apple TV, have to run the code two times to get it to both download, and draw the PDF
-(void)sermonTime {
//Check if PFFile exists, if so, display PDF, if not, blank time.
if ([self.entry[#"SermonPresIncluded"] isEqualToString:#"NO"]) {
[self blankTime];
}
else {
NSLog(#"SermonTime");
PFFileObject *thumbnail = self.entry[#"SermonPDF"];
[thumbnail getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfPath = [[documentsDirectory stringByAppendingPathComponent:[self.entry valueForKey:#"DateOfService"]] stringByAppendingString:#".pdf"];
[imageData writeToFile:pdfPath atomically:YES];
NSURL *url = [NSURL fileURLWithPath:pdfPath];
self.view.backgroundColor = [UIColor blackColor];
self.arrayOfVerses = #[#"allverses"];
CGPDFDocumentRef pdfDocument = [self openPDF:url];
[self drawDocument:pdfDocument];
}];
}
}
-(void)sermonTime {
// Check if PFFile exists, if so, display PDF, if not, blank time.
if ([self.entry[#"SermonPresIncluded"] isEqualToString:#"NO"]) {
[self blankTime];
}
else {
NSLog(#"SermonTime");
PFFileObject *thumbnail = self.entry[#"SermonPDF"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfPath = [[documentsDirectory stringByAppendingPathComponent:[self.entry valueForKey:#"DateOfService"]] stringByAppendingString:#".pdf"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:pdfPath]) {
// Use cached copy of PDF
NSURL *url = [NSURL fileURLWithPath:pdfPath];
self.view.backgroundColor = [UIColor blackColor];
self.arrayOfVerses = #[#"allverses"];
CGPDFDocumentRef pdfDocument = [self openPDF:url];
[self drawDocument:pdfDocument];
} else {
// Download and save the PDF
[thumbnail getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
if (error) {
// Handle the error
NSLog(#"Error downloading PDF: %#", error);
[self blankTime];
} else {
[imageData writeToFile:pdfPath atomically:YES];
// Use completion block to signal that the PDF is ready to display
dispatch_async(dispatch_get_main_queue(), ^{
NSURL *url = [NSURL fileURLWithPath:pdfPath];
self.view.backgroundColor = [UIColor blackColor];
self.arrayOfVerses = #[#"allverses"];
CGPDFDocumentRef pdfDocument = [self openPDF:url];
[self drawDocument:pdfDocument];
});
}
}];
}
}
}
Made some changes to the code.
It will first check if the PDF exists cache, it will use the PDF if it exists in cache and will only proceed download if it does not exists. Then, to make sure that PDF is downloaded and saved successfully you can use a completion block. With completion block, it will only proceed to draw it when the block is called to avoid the PDF does't show up.

Objective c - picker to get video path

In my app, I allow the user to record videos and I save them in this path:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [paths[0] stringByAppendingPathComponent:DestFileName];
I want to implement a video picker in my app, but the objective is to get the path of the video. I started with the basic method like this:
UIImagePickerController *videoPicker = [[UIImagePickerController alloc] init];
videoPicker.delegate = self;
videoPicker.modalPresentationStyle = UIModalPresentationCurrentContext;
videoPicker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];‌​
videoPicker.mediaTypes = #[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4];
videoPicker.videoQuality = UIImagePickerControllerQualityTypeHigh;
[self presentViewController:videoPicker animated:YES completion:nil];
The first problem is that I can not access to my recorded videos, why?
Then, this picker allows the user to play video, and when I choose one video I think that a compressed video is created and sent to our delegate method (the URL goes to a tmp repository).
I don't want to allow the user to play video and I just want the video path, is it possible with this method?
I can also get the list of files in
NSSearchPathForDirectoriesInDomains
with this:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *rootPath = path[0];
[[NSFileManager defaultManager] createDirectoryAtPath:rooPath withIntermediateDirectories:YES attributes:nil error:nil];
NSArray* mPaths = [[NSFileManager defaultManager] contentOfDirectoryAtPath:rootPath error:nil];
With this method I can found my recorded videos, but then I have to implement my own custom picker, but it can be difficult and long to implement (need to get the thumbnail for example, possible?).
To summarize:
With the UIImagePickerController, is it possible to prevent the play, to just get the path and to show our recorded videos?
With the NSFileManager, is it possible to easily create a custom video picker with thumbnail, duration etc.)
Thanks for your help
UIImagePickerController is an instance of the iOS Photos App by which you can access all of the Photos/Videos in the Device Gallery and not exclusively those belonging to your App. There is no way to have the UIImagePickerController show only the videos recorded by your App. It is also not possible to have the UIImagePickerController skip the Play/Choose step while picking a File.
Like you mentioned you can definitely write the Video file into the Apps documents directory by means of NSFileManager and hold a reference to the path which you can use for later use. I think you would probably end up creating a Model Class say "Video" with the following attributes;
a) savedPath
b) duration
c) thumbnail etc
You can then use something like a NSKeyedArchiver to encode these objects and store into a File so that you can retrieve this information later.
I finally found the solution using a custom picker, :
To get the list of local videos:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* rootPath = paths[0];
[[NSFileManager defaultManager] createDirectoryAtPath:rootPath withIntermediateDirectories:YES attributes:nil error:nil];
NSArray* mPaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:rootPath error:nil];
To get the duration and the thumbnail:
NSURL *videoURl = [NSURL fileURLWithPath:mPath];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURl options:nil];
AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generate.appliesPreferredTrackTransform = YES;
NSError *err = NULL;
CMTime time = CMTimeMake(1, 60);
CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];
UIImage *img = [[UIImage alloc] initWithCGImage:imgRef];
[m_videoFrames addObject:img];
CMTime duration = [asset duration];
int seconds = ceil(duration.value/duration.timescale);
Thanks!

MPMoviePlayerViewController not working

I have been roaming the internet for a solution I really don't know what am I doing wrong. I have been with this problem a few days now. I save the video at the following path that should be accessible to the application (Right?)
//NSDocumentDirectory doesn't work either.
NSArray *newPath = NSSearchPathForDirectoriesInDomains(NSMoviesDirectory,
NSUserDomainMask, YES);
NSString *moviesDirectory = [NSString stringWithFormat:#"%#/WebSurg",
[newPath objectAtIndex:0]];
// Check if the directory already exists
if (![[NSFileManager defaultManager] fileExistsAtPath:moviesDirectory]) {
// Directory does not exist so create it
[[NSFileManager defaultManager] createDirectoryAtPath:moviesDirectory
withIntermediateDirectories:YES attributes:nil error:nil];
}
I show the contents of this directory in a tableView in the application. When a row is tapped it should play the video. But it doesn't. It shows me the MPMoviePlayerViewController modal view and then hides it after probably what is 1 second. This is the code I use to play it:
I tried two ways of getting the path to no avail.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *moviesPath = NSSearchPathForDirectoriesInDomains(NSMoviesDirectory,
NSUserDomainMask, YES);
NSString *moviesDirectory = [NSString stringWithFormat:#"%#/WebSurg",
[moviesPath objectAtIndex:0]];
NSString *movie = [self.tableData objectAtIndex:indexPath.row];
NSString *moviePath = [NSString stringWithFormat:#"%#/%#",
moviesDirectory, movie];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
NSLog(#"MOVIEPATH: %#", moviePath);
NSString *alternatePath = [NSString stringWithFormat:#"%#/%#",
[[NSBundle mainBundle] resourcePath], movie];
NSURL *alternateMoviePath = [NSURL fileURLWithPath:moviePath];
movieViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:alternateMoviePath];
movieViewController.moviePlayer.movieSourceType= MPMovieSourceTypeFile;
NSLog(#"Movie Load State: %d", [[movieViewController moviePlayer] loadState]);
NSLog(#"Alternate movie Path: %#", alternatePath);
[self presentMoviePlayerViewControllerAnimated:movieViewController];
[movieViewController.moviePlayer play];
[self checkAndPlay];
}
- (void) checkAndPlay {
if ([[self.movieViewController moviePlayer] loadState] == MPMovieLoadStateUnknown) {
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:
#selector(checkAndPlay) userInfo:nil repeats:NO];
} else {
[self.movieViewController setModalTransitionStyle:
UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:movieViewController animated:YES];
}
}
And these are the results of the console:
2012-10-08 10:14:52.392 WebsurgTemplates[3722:17903] MOVIEPATH: /Users/THISISME/Library/Application Support/iPhone Simulator/5.0/Applications/E075DBE3-BFEA-4F6A-9DFA-2CC912E14863/Movies/WebSurg/FirstVideo.mp4
2012-10-08 10:14:52.459 WebsurgTemplates[3722:17903] Movie Load State: 0
2012-10-08 10:14:52.460 WebsurgTemplates[3722:17903] Alternate movie Path: /Users/THISISME/Library/Application Support/iPhone Simulator/5.0/Applications/E075DBE3-BFEA-4F6A-9DFA-2CC912E14863/WebsurgTemplates.app/FirstVideo.mp4
I would greatly appreciate any suggestions and help!!
UPDATE
I made no progress so far. I managed to log some other data to the console, some info that may help more at solving this problem. I tried to make a blank project taking the direct download of the video as link to play the video but it didn't work. What happens is exactly the same thing. jaydee3 said that maybe it was due because I had probably no access to NSMoviesDirectory. So I changed to NSDocumentDirectory but that didn't solve the problem. I checked that the file exists and the format in which it is saved so it can be readable by the player. Still it doesn't work. I don't know what am I doing wrong. Thanks again for the suggestions/help.
Here the results of the debug. more complete:
if ([[NSFileManager defaultManager] fileExistsAtPath:moviePath]) {
NSLog(#"FILE EXISTS");
CFStringRef fileExtension = (__bridge CFStringRef) [moviePath pathExtension];
CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
if (UTTypeConformsTo(fileUTI, kUTTypeImage)) NSLog(#"It's an image");
else if (UTTypeConformsTo(fileUTI, kUTTypeMovie)) NSLog(#"It's a movie");
else if (UTTypeConformsTo(fileUTI, kUTTypeText)) NSLog(#"It's text");
}
RESULTS
[6343:17903] MOVIEPATH: /Users/myname/Library/Application Support/iPhone Simulator/5.0/Applications/E075DBE3-BFEA-4F6A-9DFA-2CC912E14863/Documents/FirstVideo.mp4
[6343:17903] FILE EXISTS
[6343:17903] It's a movie
Okay so I managed to solve the problem and find the culprit.
In a brief note it was because the downloaded movie wasn't being saved properly (I am currently investigating the possible reasons why). And because of this the player was trying to play a file that existed, was in the correct format and the correct name but that was empty. I found this out by logging all the file sizes after download and transfer and play.
Now being more descriptive the issue was that I was downloading the movie to the NSCachesDirectory and then saving it to the NSDocumentDirectory. I found this because I started to wonder if it really found the file and if the file was "edible". It now plays the movie fine as I download it directly to the NSDocumentDirectory. Now I have to solve just in case the connection goes down. As saving in the NSCachesDirectory solved that automatically. I am open to suggestions on that. here is the code that didn't work to transfer the data from the NSCachesDirectory to NSDocumentDirectory:
NSArray *paths = NSSearchPathForDirectoriesInDomains
// HERE I changed NSCachesDirectory to NSDocumentDirectory fixed it
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *cachesDirectory = [paths objectAtIndex:0];
NSString *downloadPath = [cachesDirectory stringByAppendingPathComponent:
#"DownloadedVideo.mp4"];
NSArray *newPath = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *moviesDirectory = [NSString stringWithFormat:#"%#",
[newPath objectAtIndex:0]];
self.downloadOperation = [ApplicationDelegate.mainDownloader downloadVideoFrom:
#"http://www.blablabla.web/iphone/download.php"
toFile:downloadPath];

How Can I Save This Array of Images?

I'm very new to programming, and I jumped right into a project (I know thats not the smartest thing to do, but I'm learning as I go). The app that I'm writing has 10 UIImageViews that display a picture from the users camera roll. The code I'm using needs each of the UIImageViews to have tags. I'm currently using NSData to save the array images, and it works great, but I can't use this method anymore because NSData doesn't support the use of tags. I also can't use NSUserDefaults, because I can't save images to a plist. Here is how I'm attempting to do this (using the NSData method, which works but I have to edit this so that my tags work.)
This is my current code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
if (imageView.image == nil) {
imageView.image = img;
[self.array addObject:imageView.image];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView2.image == nil) {
imageView2.image = img;
NSLog(#"The image is a %#", imageView);
[self.array addObject:imageView2.image];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
...
- (void)applicationDidEnterBackground:(UIApplication*)application {
NSLog(#"Image on didenterbackground: %#", imageView);
[self.array addObject:imageView.image];
[self.array addObject:imageView2.image];
[self.user setObject:self.array forKey:#"images"];
[user synchronize];
}
- (void)viewDidLoad
{
self.user = [NSUserDefaults standardUserDefaults];
NSLog(#"It is %#", self.user);
self.array = [[self.user objectForKey:#"images"]mutableCopy];
imageView.image = [[self.array objectAtIndex:0] copy];
imageView2.image = [[self.array objectAtIndex:1] copy];
UIApplication *app = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:app];
[super viewDidLoad];
}
Any help or suggestions on how to edit this code so that I can save the images, while using tags is much appreciated, thanks!
EDIT: Here is my updated code:
-(IBAction)saveButtonPressed:(id)sender {
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES) objectAtIndex:0];
for (UIImageView *imageView in self.array) {
NSInteger tag = self.imageView.tag;
UIImage *image = self.imageView.image;
NSString *imageName = [NSString stringWithFormat:#"Image%i.png",tag];
NSString *imagePath = [docsDir stringByAppendingPathComponent:imageName];
[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES];
}
NSLog(#"Saved Button Pressed");
}
- (void)applicationDidEnterBackground:(UIApplication*)application {
}
-(void)viewDidLoad {
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];
NSArray *docFiles = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:docsDir error:NULL];
for (NSString *fileName in docFiles) {
if ([fileName hasSuffix:#".png"]) {
NSString *fullPath = [docsDir stringByAppendingPathComponent:fileName];
UIImage *loadedImage = [UIImage imageWithContentsOfFile:fullPath];
if (!imageView.image) {
imageView.image = loadedImage;
} else {
imageView2.image = loadedImage;
}
}
}
}
You need to use "Fast Enumeration" to parse the array's objects, and write each object to disk sequentially. First, you're going to need to add the UIImageView objects to the array instead of the UIImage property of the UIImageView, so you can recover the tag. So instead of writing
[self.array addObject:imageView.image];
It will be
[self.array addObject:imageView];
Try to follow along with my code. I inserted comments on each line to help.
-(void)applicationDidEnterBackground:(UIApplication *)application {
//Obtain the documents directory
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainmask,YES) objectAtIndex:0];
//begin fast enumeration
//this is special to ObjC: it will iterate over any array one object at a time
//it's easier than using for (i=0;i<array.count;i++)
for (UIImageView *imageView in self.array) {
//get the imageView's tag to append to the filename
NSInteger tag = imageView.tag;
//get the image from the imageView;
UIImage *image = imageView.image;
//create a filename, in this case "ImageTAGNUM.png"
NSString *imageName = [NSString stringWithFormat:#"Image%i.png",tag];
//concatenate the docsDirectory and the filename
NSString *imagePath = [docsDir stringByAppendingPathComponent:imageName];
[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES];
}
}
To load the images from disk, you'll have to look at your viewDidLoad method
-(void)viewDidLoad {
//get the contents of the docs directory
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainmask,YES) objectAtIndex:0];
//Get the list of files from the file manager
NSArray *docFiles = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:docsDir error:NULL]);
//use fast enumeration to iterate the list of files searching for .png extensions and load those
for (NSString *fileName in docFiles) {
//check to see if the file is a .png file
if ([fileName hasSuffix:#".png"]) {
NSString *fullPath = [docsDir stringByAppendingPathComponent:fileName];
UIImage *loadedImage = [UIImage imageWithContentsOfFile:fullPath];
//you'll have to sort out how to put these images in their proper place
if (!imageView1.image) {
imageView1.image = loadedImage;
} else {
imageView2.image = loadedImage;
}
}
}
}
Hope this helps
One thing you need to be aware of is that when an app enters the background it has about 5 seconds to clean up its act before it's suspended. The UIPNGRepresentation() function takes a significant amount of time and is not instantaneous. You should be aware of this. It would probably be better to write some of this code in other places and do it earlier than at app backgrounding. FWIW
You can use the [NSbundle Mainbundel] to store that images.
To get path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
First, there's still a problem in your for loop.
for (UIImageView *imageView in self.array) {
NSInteger tag = self.imageView.tag;
UIImage *image = self.imageView.image;
// ...
}
Before you make any other changes, you must understand why. imageView is your for loop control variable, which changes on each iteration through the loop. self.imageView is a different thing. It is the first of the 10 imageViews attached to your viewController. Every time this loop cycles, it looks at the first imageView, and only the first.
As for why saving doesn't work, it's probably because the arrays elsewhere aren't working. Add some logging to make sure there's something in the array, and that it has as many elements as you expect.
-(IBAction)saveButtonPressed:(id)sender {
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES) objectAtIndex:0];
// Log to make sure the views expected have previously been stored.
// If the array is empty, or shorter than expected, the problem is elsewhere.
NSLog(#"Image view array before saving = %#", self.array);
for (UIImageView *imageViewToSave in self.array) {
NSInteger tag = imageViewToSave.tag;
UIImage *image = imageViewToSave.image;
NSString *imageName = [NSString stringWithFormat:#"Image%i.png",tag];
NSString *imagePath = [docsDir stringByAppendingPathComponent:imageName];
// Log the image and path being saved. If either of these are nil, nothing will be written.
NSLog(#"Saving %# to %#", image, imagePath);
[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:NO];
}
NSLog(#"Save Button Pressed");
}

How can I load only the latest saved image from the document directory?

I would like to show the latest added image that I saved into my document directory.
In the code below I tried to first count all the images that are in ImageData.plist and then show the latest image by subtracting 1.
It doesn't show any image so I am doing something wrong, but can't figure out what exactly?
Thx in advance.
- (void)viewDidLoad {
[super viewDidLoad];
//Show latest added image from document directory
//Add UIImageView
UIImageView *guideSheet = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)]autorelease];
//Add latest image
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:#"ImageData.plist"];
NSArray *plistFile = [[NSArray alloc] initWithContentsOfFile:path];
NSInteger plistCount = [plistFile count];
for (NSInteger i = plistCount; i < (plistCount - 1); i++) {
// Show image
NSString *imageName = [NSString stringWithFormat:#"ImageData/ImageData%i.jpg", i];
UIImage* content = [UIImage imageWithContentsOfFile:imageName];
guideSheet.image = content;
[self.view addSubview:guideSheet];
}
[plistFile release];
}
When you created the NSString object imageName, you did not append the documents directory location. Therefore, the full path of the image it's using is /ImageData/ImageData%i.jpg.
NSString *imageName = [documentsDirectory stringByAppendingPathComponent:#"ImageData/ImageData%i.jpg", i];
Should work if you were able to save the images correctly into the documents directory (if these images are in the mainBundle, then you'll have to use pathForResource instead of the above).