0

「[subview touchesBegan:touches withEvent:event];」という行で EXC_BAD_ACCESS を取得します。その行を削除すると、すべてがうまくいきます。私は間違って何をしていますか?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    for(UIView *subview in [self.view subviews]) {
        NSLog(@"%@", subview);
        NSLog(@"%@", touches);
        NSLog(@"%@", event);
        [subview touchesBegan:touches withEvent:event];
    }
}
4

2 に答える 2

-2

「touchesBegan:touches withEvent:event」を直接呼び出すことはできません。これは、システムによって呼び出される iOS のデリゲート メソッドです。タッチイベントをサブビューに送信したい場合は、「touchesBegan:」のようなメソッドを定義しないのはなぜですか? touchesBeganでやりたいですか?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for(UIView *subview in [self.view subviews]) { NSLog(@"%@", subview); NSLog(@"%@", touches); NSLog(@"%@", event); [subview touchesBegan]; } }

于 2013-07-10T03:00:52.027 に答える