我想设置一个委托来处理基于Tinder类型示例(https://github.com/cwRichardKim/TinderSimpleSwipeCards)的子视图上的滑动操作。我在做什么我的ViewController子视图委托错了?
我打开我的背景观点:
SwipeController.h
#import "DraggableView.h"
@interface SwipeViewController : UIViewController <DraggableViewDelegate>
//methods called in DraggableView
-(void)cardSwipedUp:(UIView *)card;
-(void)cardSwipedLeft:(UIView *)card;
-(void)cardSwipedRight:(UIView *)card;
@end
SwipeViewController.m
....
// since we have all the data, lets show some cards
DraggableViewBackground *draggableBackground = [[DraggableViewBackground alloc]initWithFrame:self.view.frame];
[draggableBackground setupViewWithImages:_results];
[self.view addSubview:draggableBackground];
....
-(void)cardSwipedUp:(UIView *)card;
{
NSLog(@"Swiped up");
}
-(void)cardSwipedLeft:(UIView *)card;
{
NSLog(@"Swiped Left");
}
-(void)cardSwipedRight:(UIView *)card;
{
NSLog(@"Swiped Right");
}
...
DragableBackground.m
...
// assign the delegate
SwipeViewController *swipeViewController = [[SwipeViewController alloc] initWithNibName:nil bundle:nil];
draggableView.delegate = swipeViewController;
return draggableView;
...
最后我DragableV IEW,这是我想从SwipeController到委托:
@protocol DraggableViewDelegate <NSObject>
-(void)cardSwipedUp:(UIView *)card;
-(void)cardSwipedLeft:(UIView *)card;
-(void)cardSwipedRight:(UIView *)card;
@end
@interface DraggableView : UIView
@property (weak) id <DraggableViewDelegate> delegate;
你得到的结果是什么,你不满意?如果有任何方法可以更清楚地解决问题,它将有助于诊断它。 – diatrevolo
cardSwipedUp,cardSwipedLeft和cardSwipeRight没有在SwitchController委托中被触发。 – LeviXC