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

iOS Build a Self-Destructing Message iPhone App Retrieving and Viewing Data from Parse.com Viewing Images Using UIImageView

problem with prepareForSegue

I have a problem; the segue associated at the UIViewController of the imageView it doesn't work. When i click in the simulator in the cell with the message with an image, nothing happens. I have checked all the code in all the view controller and the cell identifier and segue identifier in the stoyboard too. i've checked the class name in the data browser of parse too. I use Xcode 5.1.1.

i Need help

2 Answers

send your code!

ok thanks!

inBoxViewController M

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { PFObject *message = [self.messages objectAtIndex:indexPath.row];

NSString *fileType = [message objectForKey:@"fileType"];

if ([fileType isEqualToString:@"image"]){

    [self performSegueWithIdentifier:@"showImage" sender:self];
    }
else {

}

}

  • (IBAction)logout:(id)sender { [PFUser logOut]; [self performSegueWithIdentifier:@"showLogin" sender:self]; }

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"showLogin"]) { [segue.destinationViewController setHidesBottomBarWhenPushed:YES]; } else if ([segue.identifier isEqualToString:@"showImage"]) { [segue.destinationViewController setHidesBottomBarWhenPushed:YES]; ImageViewController *imageViewController = (ImageViewController *)segue.destinationViewController; imageViewController.message = self.selectedMessage; } }

imageViewController M

@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];

}

I would perform some kind of test to make sure that the method is being called. Maybe try putting a breakpoint there!

Thank you Neil, but i've fixed it!!! I don't know how and i don't understand but now it works! Thank you!