What am I doing wrong?
The NSLog does return the action of Swipes but the image does not change.. I tried everything I know. Help Please?
I am working with Parse.com and I have a PFQueryTableView that segues a cell to a DetailView Controller. That Detail view has a PFImageView and I need it to swipe to different Images called from the Parse Data Browser (same class).
This is my .m code:
#import "BellezaDetailViewController.h"
#import "BellezaView.h"
@interface BellezaDetailViewController ()
@end
@implementation BellezaDetailViewController
@synthesize lookPhoto, bellezaView, activityIndicator;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)handleSwipe:(UISwipeGestureRecognizer *)swipe {
if (swipe.direction == UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"Left Swipe");
}
if (swipe.direction == UISwipeGestureRecognizerDirectionRight) {
NSLog(@"Right Swipe");
}
}
- (void)viewDidLoad
{
[super viewDidLoad];{
[activityIndicator startAnimating];
[activityIndicator performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:10];
NSLog(@"Downloading Look");
self.lookPhoto.file = bellezaView.imagenDos;
[lookPhoto loadInBackground];
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
// Setting the swipe direction.
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
// Adding the swipe gesture on image view
[lookPhoto addGestureRecognizer:swipeLeft];
[lookPhoto addGestureRecognizer:swipeRight];
}
}
- (void)swipeRecognized:(UISwipeGestureRecognizer *)swipe{
if(swipe.direction == UISwipeGestureRecognizerDirectionLeft){
self.lookPhoto.file = bellezaView.imagenTienda;
[lookPhoto loadInBackground];
}
if(swipe.direction == UISwipeGestureRecognizerDirectionRight){
self.lookPhoto.file = bellezaView.imagenTienda;
[lookPhoto loadInBackground];
}
}
- (void)viewDidUnload {
[self setLookPhoto:nil];
[super viewDidUnload];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
For anyone who needs help on the same thing.. this was my error:
The action and the handler should have matched: (now it works fine)
UISwipeGestureRecognizer swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(**handleSwipe**:)];
- (void)**swipeRecognized**:(UISwipeGestureRecognizer *)swipe{ if(swipe.direction == UISwipeGestureRecognizerDirectionLeft){ self.lookPhoto.file = bellezaView.imagenTienda; [lookPhoto loadInBackground]; }
What's in between *... * should have matched.