Hey guys,
So i have an application that when you push a button it opens the camera and you can take a picture. After you take the picture you can click use and it displays the picture in the same view in a UIImageView.
What i need to do is when i click "use" i want the image to be sent to a different viewController to view the image. My problem is right now it is not displaying in my new viewController and is just showing a white screen.
I don't think i can use a UIImageView to display the image in my new viewController because once the image is sent it is programatically broken up into puzzle pieces that you can move around.
I can provide my code in advance, but would be ALOT to post here!
thanks in advance!!
Steve!
__________________
Don't be a quitter! Never give up and keep pushing to succeed at the things you love!
haha nothing wrong with more then 1
She hates me working on my computer!
So i am guessing since i havnt explored to much with sandbox, when i use NSUserDefaults, i can take or select an image from my album and it will be saved in sandbox, then when i need to get that image in a different viewController, i can just call it from sandbox to retrieve the image and then use it?
Im gonna start researching this, very interesting and useful solution!
Thanks!!
__________________
Don't be a quitter! Never give up and keep pushing to succeed at the things you love!
Yes, you are right. Except I think using the app sandbox directly probably is better than using NSUserDefault's "object".
Here is a code block that I always use in my apps.
Saving:
Code:
-(void)savetheimage:(NSString *)imgname:(UIImage *)fromimage {
// Now, we have to find the documents directory so we can save it
// Note that you might want to save it elsewhere, like the cache directory,
// or something similar.
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
// Now we get the full path to the file
NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imgname];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(fromimage)];
[imageData writeToFile:fullPathToFile atomically:YES];
}
Yes, you are right. Except I think using the app sandbox directly probably is better than using NSUserDefault's "object".
Here is a code block that I always use in my apps.
Saving:
Code:
-(void)savetheimage:(NSString *)imgname:(UIImage *)fromimage {
// Now, we have to find the documents directory so we can save it
// Note that you might want to save it elsewhere, like the cache directory,
// or something similar.
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
// Now we get the full path to the file
NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imgname];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(fromimage)];
[imageData writeToFile:fullPathToFile atomically:YES];
}
It's basically getting the full path of the image (in the sandbox), and loading it up in a UIImage using initWithContentsOfFile. Pretty simple.
Thanks for the example. Wil give it a try tonight. When I take a picture or choose from album I can easily display it in a UIImageView in the current viewController but the thing is I don't think when I want to display it in my second viewController I can't use a UIimageView because that will cause the image to be static and if it's a static image I will not be able to break the image up in puzzle pieces and move them around. It would almost have to break up the image and put each broken piece in its own UIImageView programmatically.
But I will see what happens! Never know!
Thanks steve
__________________
Don't be a quitter! Never give up and keep pushing to succeed at the things you love!
Well, you are not supposed to be calling/messing with objects in another viewController from current viewcontroller anyways - cuz then it would violate the MVC pattern. if have to pass it around, use delegates (im not good at this yet), or as i explained, via a middle man (nsuserdefaults/sandbox).
Well, you are not supposed to be calling/messing with objects in another viewController from current viewcontroller anyways - cuz then it would violate the MVC pattern. if have to pass it around, use delegates (im not good at this yet), or as i explained, via a middle man (nsuserdefaults/sandbox).
That's okay I will test with different ideas. But every bit of info I get helps !
Thanks
__________________
Don't be a quitter! Never give up and keep pushing to succeed at the things you love!