2013年5月12日日曜日

[iOS]UIImageViewにswipeのgestureをつけたい。



大したことないすけど、UIViewはそのままデフォルトで、gestureを追加できるんだけど、UIImageViewの場合、userInteractionEnabled = YES をしてからaddGestureRecognizerをしてあげればよいです。


UIImage *top_nav = [UIImage imageNamed:@"map_bg.png"];
UIImageView *map_top = [[UIImageView alloc] initWithImage:top_nav];



map_top.userInteractionEnabled = YES;
[map_top addGestureRecognizer:swipeUpGesture];


これだけです。