Hi all, I'm working on my first iPhone app and I ran into a problem. Here's what I got...
I have a Navigation-Based app where each cell in the table has a UILabel and a UIImageView. Tapping a cell goes to a ViewController where the data from the UILabel and UIImageView can be modified. In this ViewController there is a text field, a UIImageView and a Button which calls up the built-in ImagePickerController.
Whenever I add/modify an item and return to the TableView, the UILabel is showing the appropriate changes. However, I can't seem to get the image "out" of the ViewController and back to the TableView. I did some checking and it seems that the image is simply nil whenever I go back to the TableView.
Here's my code...
ViewController:
Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
imageView.image = image; //UIImageView in the ViewController is updated successfully
self.item.itemPic = image; //itemPic set. a check confirmed it's not nil
[picker dismissModalViewControllerAnimated:YES];
}
- (IBAction) updateName:(id) sender
{
self.item.itemName = self.itemNameTextField.text;
}
Hi all, I'm working on my first iPhone app and I ran into a problem. Here's what I got...
I have a Navigation-Based app where each cell in the table has a UILabel and a UIImageView. Tapping a cell goes to a ViewController where the data from the UILabel and UIImageView can be modified. In this ViewController there is a text field, a UIImageView and a Button which calls up the built-in ImagePickerController.
Whenever I add/modify an item and return to the TableView, the UILabel is showing the appropriate changes. However, I can't seem to get the image "out" of the ViewController and back to the TableView. I did some checking and it seems that the image is simply nil whenever I go back to the TableView.
Here's my code...
ViewController:
Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
imageView.image = image; //UIImageView in the ViewController is updated successfully
self.item.itemPic = image; //itemPic set. a check confirmed it's not nil
[picker dismissModalViewControllerAnimated:YES];
}
- (IBAction) updateName:(id) sender
{
self.item.itemName = self.itemNameTextField.text;
}
Thanks for that link. I didn't even realize that memory leak was in my app!
Unfortunately, I don't think the information there helps with my problem (unless I missed something). I'm having this problem even when there's only one record with one image, so I don't think my issue is memory-management related.
My problem is simply this: In my ViewController, I can set the text and image values of my Item to my TextField and UIImage successfully. When I try to get these two values "out" on the ViewController and into the Item in my TableView, only the TextField is being populated.
So is there some special method required here when dealing with UIImages? Is this simply not possible for whatever reason? Or am I just overlooking something simple and stupid?
you don't provide enough context to explain for sure but it seems like you just aren't storing the image anywhere. how does newItem get passed into setItem? are these separate classes/objects?
I fixed it. I didn't have @synthesize item in ItemCell.m
So now I have that part working, but I've also run into a new issue. I'm able to select an image using the UIImagePickerController and then save the image. However, whenever I restart the app and load the saved image, it's turned -90 degrees!
This only happens with images that were selected from the picker. Images taken with the camera within the app seem to be fine. Also, I'm only seeing this on the iPhone itself, the simulator isn't having any issues.
I don't know what I could be doing wrong since the same code is saving both the selected images and the camera images. Is this a known problem with the iPhone? I tried Googling, but all of the results were about how to get an image to rotate, so that didn't help.
Hey try this [image CGImage]; this will give u a actual image,
Otherwise the problem is with Context check for context is changing the image properties!!!
Hey try this [image CGImage]; this will give u a actual image,
Otherwise the problem is with Context check for context is changing the image properties!!!
Could you explain that a little more? I did a little bit of research and all I could find on this was information on drawing an image with quartz, which I'm not doing. I'm simply loading a UIImage into a UIImageView, and whenever I do that with an image that originated from the iPhone camera, it ends up rotated -90.
I should probably point out that I'm currently storing the images in the database as blobs and reading/writing the image data as NSData. (I know this isn't the best way to do that, and I'll likely change it.) Could this be part of the problem? If I change my code to store the images as files instead, would that help?
By the way, thanks for all the help so far. I REALLY appreciate it!