実行時にuigesturerecognizerを使用してuiimageを作成します
-
29-09-2019 - |
質問
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];
所属していません StackOverflow