Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

camitampa

macrumors newbie
Original poster
Apr 18, 2012
16
0
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:

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
 
Last edited by a moderator:

camitampa

macrumors newbie
Original poster
Apr 18, 2012
16
0
First, thanks for taking a look.
in the tableviewcontroller

Code:
- (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;
       [SIZE="4"] controller.photo = photo[/SIZE];
      

    }
}


----------

Dont know where the purple faces came from in that last post!
 
Last edited by a moderator:

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
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

macrumors newbie
Original poster
Apr 18, 2012
16
0
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.