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 trialJonah Kesoyan
2,055 PointsShow image when clicked in new VC from Parse!
So I want to do exactly all this, except all my pictures are in parse. And I think my problem is the code in PhotoController.h and .m, what code do I need to write so when I click each individual cell, it will get bigger, THANKS FOR THE HELP
PhotoController.h
#import <Foundation/Foundation.h>
#import <Parse/Parse.h>
@interface PhotoController : NSObject
@property (nonatomic) NSArray *photos;
+ (void)imageForPhoto:(NSDictionary *)photo size:(NSString *)size completion:(void(^)(UIImage *image))completion;
@end
PhotoController.m
#import "PhotoController.h"
@implementation PhotoController
+ (void)imageForPhoto:(NSDictionary *)photo size:(NSString *)size completion:(void(^)(UIImage *image))completion {
if (photo == nil || size == nil || completion == nil) {
return;
}
PFQuery *query = [PFQuery queryWithClassName:@"Photo"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(@"%d", objects.count);
}
}];
}
@end
5 Answers
Ben Jakuben
Treehouse TeacherHi Jonah,
Where are you calling this code from? Can you paste in the code from your inbox? Are you performing a segue to this view controller? I'm confused as to why this would be a static class method (+ instead of -).
Jonah Kesoyan
2,055 PointsAnd here is the PhotoCell.m
@implementation PhotoCell
@synthesize parseImage;
-(void)setPicture:(NSDictionary *)picture {
_picture = picture;
// [PhotoController imageForPhoto:_picture size:@"thumbnail" completion:^(UIImage *image) {
// self.imageView.image = image;
// }];
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.imageView = [[PFImageView alloc] init];
[self.contentView addSubview:self.imageView];
}
return self;
}
-(void)layoutSubviews {
[super layoutSubviews];
self.imageView.frame = self.contentView.bounds;
}
@end
Jonah Kesoyan
2,055 PointsSo once again, I want to click on a cell in a collectionview and have it go to a different view controller, like instagram
Jonah Kesoyan
2,055 PointsBy the way, here is my didSelectItemAtIndexPath in my collection view class:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *photo = self.photos[indexPath.row];
SeparateImageViewController *viewController = [[SeparateImageViewController alloc] init];
viewController.modalPresentationStyle = UIModalPresentationCustom;
viewController.transitioningDelegate = self;
viewController.photo = photo;
[self presentViewController:viewController animated:YES completion:nil];
}
Ben Jakuben
Treehouse TeacherSo sorry for my late reply here. Are you still having trouble with this? Where exactly is it breaking?
Jonah Kesoyan
2,055 PointsJonah Kesoyan
2,055 PointsWell, here is my DetailViewController.m. So after you click on each cell, it will go here.