UIImageView
いくつかのサブクラス インスタンスの背後にサブクラス (フルスクリーン)を追加するとUIButton
、それらのボタンはタッチの受信を停止し、機能しなくなります。ユーザーのタッチへの接続を復元するために試したことはありません。
私は試しました:
a)UIImageView
正面図(タッチを受け取る)にサブクラスを使用し、 setUserInteractionEnabled
YESであることを確認します。結果:UIButtons
が存在する場合、応答していませんUIView
。
b) 正しいことを期待して、フロント ビューからビュー コントローラーにタッチを明示的に渡します。結果:UIButtons
タッチに反応しません。
c)前面のタッチが受信されたときに操作したいボタンで、メソッドとメソッドを直接touchesBegan
呼び出しtouchesMoved
ます。結果: 驚くべきことに、ボタンにタッチ イベントを詰め込んでもボタンが反応しません。touchesEnded
UIView
d) フロント ビューから にタッチを渡し、UIViewController
すべてのサブビューを反復してタッチを手動で配布します。touchesBegan
これを行う方法を示す方法を含めました。ループが無限に実行されると、最初のビューを超えて進行することはありません (タイプは ですFrameUIView
)。
この問題は、適切なビュー階層またはレスポンダー チェーンを理解していないことが原因である可能性が高いことはわかっています。
ボタンの後に作成された最後のビューにコメントすると、ボタンは正常に機能します。UIButtons
この点で特別なことはありますか?
これがコードです。
その中にUIViewControllerサブクラスがあります:
- (void)loadView {
mainAppView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.view = mainAppView;
frameImageView = [[FrameUIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
frameImageView.image = [UIImage imageNamed:[[[ThemeController sharedInstance] currentTheme] frameImageFilename]];
[frameImageView setUserInteractionEnabled:YES];
[mainAppView addSubview:frameImageView];
zoomInButton = [[CustomUIButton alloc] initWithFrame:CGRectMake(controlsOriginX + zoomWidth + lightWidth, controlsOriginY, zoomWidth, controlsHeight)];
[zoomInButton setTitle:@"+" forState:UIControlStateNormal];
[[zoomInButton titleLabel] setFont:[UIFont systemFontOfSize:28]];
[zoomInButton addTarget:self action:@selector(doMyAction) forControlEvents:UIControlEventTouchDown];
[zoomInButton addTarget:self action:@selector(cancelMyAction) forControlEvents:UIControlEventTouchUpInside];
[mainAppView addSubview:zoomInButton];
FrameFrontUIView *frameFrontImageView = [[FrameFrontUIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
frameFrontImageView.image = [UIImage imageNamed:[[[ThemeController sharedInstance] currentTheme] frameFrontImageFilename]];
[frameFrontImageView setUserInteractionEnabled:YES];
[mainAppView addSubview:frameFrontImageView];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (UIView *view in self.view.subviews) {
NSLog(@"view is a %@", [view description]);
[view touchesBegan:touches withEvent:event];
}
}
これを行う方法に関するヒントを知っている人は誰でも、インターネットと Cookie を獲得できます。ロシアンルーレットの騒乱のためのリボルバーも受け入れます. ありがとうございました。