我想設置一個委託來處理基於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