質問

uiimageviewのタッチを検出するいくつかのuigesturerecognizersが必要な、特定のサイズの新しいuiimageviewを追加できるようにしたいと思います。

サブクラスのuiimageviewはどのようにして、これをどのように達成するのでしょうか?

ユーザーに、実行時に必要なようにUIIMAGEViewを追加できるようにし、GestureRecognizerによりビューを操作できるようにします。

ありがとう

役に立ちましたか?

解決

ユーザーインタラクションを有効にするのを忘れただけだと思います。

UIImageView *imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"foo.png"]] autorelease];
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)] autorelease];
[imageView addGestureRecognizer:tapGesture];
[self.view addSubview:imageView];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top