滑动手势识别器PFImageView

时间:2014-02-28 02:43:21

标签: ios uiimageview parse-platform uiswipegesturerecognizer detailview

我做错了什么?

NSLog确实返回了Swipes的动作,但图像没有改变..我尝试了所有我知道的东西。请帮帮忙?

我正在使用Parse.com,我有一个PFQueryTableView,它将一个单元格细分为一个DetailView控制器。那个Detail视图有一个PFImageView,我需要它来滑动到从Parse Data Browser(同一个类)调用的不同图像。

这是我的.m代码:

    #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

1 个答案:

答案 0 :(得分:0)

对于在同一件事上需要帮助的人......这是我的错误:

动作和处理程序应该匹配:(现在工作正常)

    UISwipeGestureRecognizer swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(**handleSwipe**:)];


    - (void)**swipeRecognized**:(UISwipeGestureRecognizer *)swipe{ if(swipe.direction == UISwipeGestureRecognizerDirectionLeft){ self.lookPhoto.file = bellezaView.imagenTienda; [lookPhoto loadInBackground]; }

* ... * 之间的内容应该匹配。