-1
このアニメーションをスワイプして機能させることができません。 ここまでは私のコードです。アニメーションのみですが、画面上をスワイプするとオブジェクトが機能しません。UIビューのアニメーションを上下にスワイプします
ViewController.m
// notificationView
//
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NotificationView *notifications= [[NotificationView alloc] initWithFrame:CGRectMake(200,200,200,200)];
notifications.backgroundColor =[ UIColor blueColor];
[self.view addSubview:notifications];
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:
@selector(swipeUp:)];
[notifications addGestureRecognizer:swipeUp];
swipeUp.direction=UISwipeGestureRecognizerDirectionUp;
UISwipeGestureRecognizer *swipeDown=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:
@selector(swipeDown:)];
swipeDown.direction=UISwipeGestureRecognizerDirectionDown;
[notifications addGestureRecognizer:swipeDown];
[UIView animateWithDuration:0.5 animations:^{
notifications.center=CGPointMake(150,150);}]; };
-(void) swipeUp:(id) sender {
UISwipeGestureRecognizer *swipe = (UISwipeGestureRecognizer *) sender;}
-(void) swipeDown:(id) sender { }
@end
デリゲートが不足していると思います。ヘッダーにUIGestureRecognizerDelegateを設定します。 –