ImageView Help

Discussion in 'iPhone/iPad Programming' started by camitampa, Sep 17, 2012.

  1. camitampa, Sep 17, 2012
    Last edited by a moderator: Sep 17, 2012

    macrumors newbie

    Joined:
    Apr 18, 2012
    #1
    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
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    How / where does setPhoto: get called?
     
  3. camitampa, Sep 17, 2012
    Last edited by a moderator: Sep 17, 2012

    thread starter macrumors newbie

    Joined:
    Apr 18, 2012
    #3
    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!
     
  4. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
  5. thread starter macrumors newbie

    Joined:
    Apr 18, 2012
    #5
    Thank you. I didn't know about the code button.
     
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    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.
     
  7. thread starter macrumors newbie

    Joined:
    Apr 18, 2012
    #7
    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
     

Share This Page