25
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UIScrollViewに追加したUIImageViewのタッチイベントを取得する

Last updated at Posted at 2013-06-01

UIScrollViewにカテゴリとして追加する。
タッチされたら次のレスポンダーへ渡す

UIScrollView+TouchEvent.h
#import <UIKit/UIKit.h>

@interface UIScrollView (UIScrollView_TouchEvent)
@end
UIScrollView+TouchEvent.m
#import "UIScrollView+UIScrollView_TouchEvent.h"

@implementation UIScrollView (UIScrollView_TouchEvent)

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [[self nextResponder] touchesBegan:touches withEvent:event];
}

@end

下記ファイルに追加することでプロジェクト全体で利用出来る。

hoge-Prefix.pch
#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import <CoreData/CoreData.h>
    #import "UIScrollView+UIScrollView_TouchEvent.h"
#endif

使う箇所でタッチイベントをYESに設定する。

HogeViewController.m
        imageView.userInteractionEnabled = YES;
25
25
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?