PDA

View Full Version : ImageView Help




camitampa
Sep 17, 2012, 04:56 PM
I would greatly appreaciate any help with this code. Yes it is from the Stanford course exercises. I am new to Objective c though I am not new to programming. I passed the half million debugged lines of code somewhere around 2005. If you have purchased a used car in the southeast in the 80's 90's and 2000's there is a good chance the finance man used software I wrote. I'm just telling this so you know I have a small bit of experience as a programmer.


My problem is I can't get anything to display in the UIImageView.

here's the code:

#import "PhotoImageViewController.h"
#import "FlickrFetcher.h"

@interface PhotoImageViewController () <UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;


@end

@implementation PhotoImageViewController


@synthesize photo = _photo;
@synthesize imageView = _imageView;
@synthesize scrollView = _scrollView;

NSURL *photoURL;



-(void)setPhoto:(NSDictionary *)photo{

_photo = photo;
photoURL = [FlickrFetcher urlForPhoto:photo format:FlickrPhotoFormatLarge];
NSLog(@"%@",photoURL);
NSData *data = [[NSData alloc] initWithContentsOfURL:photoURL];
UIImage *tmpImage = [[UIImage alloc] initWithData:data];
[self.imageView setImage:tmpImage];

}
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return self.imageView;
}


-(void)viewDidLoad{
//self.scrollView.delegate = self;
[super viewDidLoad];
//self.scrollView.contentSize = self.imageView.image.size;
}


I put a break in the setPhoto method and all of the variables are ok. But nothing displays.

My segue seems ok and gets called.
The connections to the imageview appear to be correct.
If anyone sees a reason why this displays nothing I'd be very happy to get some guidance.
I'm stuck here now for over a week and I have nobody local to ask for help.
Thank you



dejo
Sep 17, 2012, 05:25 PM
How / where does setPhoto: get called?

camitampa
Sep 17, 2012, 06:27 PM
First, thanks for taking a look.
in the tableviewcontroller

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
photo = [self.photos objectAtIndex:indexPath.row];

[self performSegueWithIdentifier:@"show location photo" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"show location photo"]) {
PhotoImageViewController *controller = (PhotoImageViewController *)segue.destinationViewController;
controller.photo = photo;


}
}

----------

Dont know where the purple faces came from in that last post!

dejo
Sep 17, 2012, 06:44 PM
Dont know where the purple faces came from in that last post!

You're not tagging your code snippets properly. Please see this sticky: Posting code, please use the [CODE] tags (http://forums.macrumors.com/showthread.php?t=747660)

camitampa
Sep 17, 2012, 07:11 PM
Thank you. I didn't know about the code button.

dejo
Sep 17, 2012, 07:16 PM
I didn't know about the code button.

It's always a good idea to review all the stickies in a forum before you create a thread in it.

As for your issue: I'm not sure what the issue might be. Have you tried stepping through setPhoto:? Perhaps the photoURL doesn't actually contain a valid image? Just reaching at straws here.

camitampa
Sep 17, 2012, 07:45 PM
It's always a good idea to review all the stickies in a forum before you create a thread in it.

How true, my bad, sorry.

I've tried loading an image that I added to supporting files in Xcode with the same result. I'll figure it out. It's got to be something simple.

Thanks