0

上記のボタンを押したことを認識するために、いくつかのUIButtonを取得したUIScrollViewを使用しています。メソッドを書き換えるUIScrollViewのサブクラスを作成しました

- (BOOL) touchesShouldCancelInContentView (UIView *) view

しかし、タッチが旅である場合にのみその方法に入り、それ以上画面を押しても決して来ません。

私が作成したUIScrollView:

`

CGSize containerSize = CGSizeMake(320.0f, 480.0f);
CGSize containerSize2 = CGSizeMake(640.0f, 960.0f);
self.scrollView = [[UIScrollViewWithButtons alloc] initWithFrame:(CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=containerSize}];

[self.scrollView setMinimumZoomScale:0.5f];
[self.scrollView setMaximumZoomScale:1.0f];
[self.scrollView setZoomScale:0.5f];
[self.scrollView setDelegate:self];

self.scrollView.bounces = NO;
self.scrollView.bouncesZoom = NO;
self.scrollView.delaysContentTouches = NO;

self.scrollView.userInteractionEnabled = YES;

[self.scrollView setContentInset:UIEdgeInsetsZero];

[self.view addSubview:self.scrollView];

self.containerView = [[UIView alloc] initWithFrame:(CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=containerSize2}];
self.containerView.userInteractionEnabled = YES;
[self.scrollView addSubview:self.containerView];

[self.scrollView setClipsToBounds:NO];

//instanciar uimageview
fondo = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 640, 960)];
[self.containerView addSubview:fondo];
[fondo setImage:[UIImage imageNamed:@"Grande.png"]];

self.scrollView.contentSize = containerSize2;

とボタン追加

imagen = [UIButton buttonWithType:UIButtonTypeCustom];
        [imagen addTarget:self action:@selector(pulsadoIzq) forControlEvents:UIControlEventTouchUpInside]; 

        [imagen setTitle:@"" forState:UIControlStateNormal];
        [imagen setFrame:CGRectMake(xUser, yUser, 50.0f, 50.0f)];
        [imagen setImage:[UIImage imageNamed:@"boton.png"] forState:UIControlStateNormal];
[self.containerView addSubview:fichaUserIzq];

        imagen.center = CGPointMake(xUser, yUser);`enter code here`

画面上のタップをボタンにキャプチャする必要があります。どうすればよいですか?

このコードを実装したかどうかも知りたいです。

img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"img.png"]];
UIPanGestureRecognizer *panRecg = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(imgDragged:)];

img.userInteractionEnabled = YES;
[img addGestureRecognizer:panRecg];
img.center = CGPointMake(160, 436);

[self.scrollView addSubview:img];

画像をクリックしても何も起こらず、メソッドに入らず、押してドラッグしたときにのみ表示されます。この画像を押したときもキャプチャしたいので、動いたときだけキャプチャします。

4

1 に答える 1