Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

UIImageView *notWorking

For me, in the self destructing message app for iOS, the UIImageView doesn't show up at all when i click a message in my inbox? I have the lines that the tutorials say to have, but it's not working, maybe i missed something. Please help<>any help is appreciated:)

2 Answers

post the code where you set the image property of the imageview.

.h

import <UIKit/UIKit.h>

import <Parse/Parse.h>

@interface ImageViewController : UIViewController

@property (nonatomic, strong) PFObject *message; @property (nonatomic, retain) IBOutlet UIImageView *imageView;

@end

.m

import "ImageViewController.h"

@interface ImageViewController ()

@end

@implementation ImageViewController

  • (void)viewDidLoad { [super viewDidLoad]; PFFile *imageFile = [self.message objectForKey:@"file"]; NSURL *imageFileUrl = [[NSURL alloc] initWithString:imageFile.url]; NSData *imageData = [NSData dataWithContentsOfURL:imageFileUrl]; self.imageView.image = [UIImage imageWithData:imageData];

    NSString *senderName = [self.message objectForKey:@"senderName"]; NSString *title = [NSString stringWithFormat:@"Sent from %@", senderName]; self.navigationItem.title = title; }

  • (void)viewDidAppear:(BOOL)animated { [super viewWillAppear:animated];

    if ([self respondsToSelector:@selector(timeout)]) { [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector (timeout)userInfo:nil repeats:NO]; } else { NSLog(@"Error:selector missing!"); } }

pragma mark - Helper methods

  • (void)timeout { [self.navigationController popViewControllerAnimated:YES]; }

@end