【问题标题】:Swipe Gesture Recognizer PFImageView滑动手势识别器 PFImageView
【发布时间】:2014-02-28 02:43:20
【问题描述】:

我做错了什么?

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

【问题讨论】:

  • 我已经编辑了你的代码。请尝试添加该行。此外,Imageview 的 userInteractionEnabled 属性似乎设置为 NO。请将此设置为“是”。
  • 感谢您的宝贵时间!我发现了我的错误!!操作集错误并且没有调用句柄:对于在同一件事上需要帮助的任何人..这是我的错误: UISwipeGestureRecognizer swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)]; - (void)**swipeRecognized*:(UISwipeGestureRecognizer *)swipe{ if(swipe.direction == UISwipeGestureRecognizerDirectionLeft){ self.lookPhoto.file = bellezaView.imagenTienda; [lookPhoto loadInBackground]; } 粗体字应该匹配。

标签: ios uiimageview parse-platform uiswipegesturerecognizer detailview


【解决方案1】:

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

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

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


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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-20
    • 1970-01-01
    • 2016-08-04
    • 2015-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多