アプリ内にスプリングボードのようなインターフェイスを作成しようとしています。UIScrollView に追加された UIButtons を使用しようとしています。私が実行している問題は、ボタンがUIScrollViewにタッチを渡さないことです-フリック/スライドしようとしてボタンを押すと、UIScrollViewに登録されませんが、間のスペースをフリックするとボタンが機能します。ボタンに触れるとクリック/機能します。
ボタンがタッチ イベントをその親 (スーパービュー) に送信するように強制するプロパティまたは設定はありますか? UIScrollView を追加する前に、ボタンを別のものに追加する必要がありますか?
これが私のコードです:
//init scrolling area
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 480, 480)];
scrollView.contentSize = CGSizeMake(480, 1000);
scrollView.bounces = NO;
scrollView.delaysContentTouches = NO;
//create background image
UIImageView *rowsBackground = [[UIImageView alloc] initWithImage:[self scaleAndRotateImage:[UIImage imageNamed:@"mylongbackground.png"]]];
rowsBackground.userInteractionEnabled = YES;
//create button
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
btn.frame = CGRectMake(100, 850, 150, 150);
btn.bounds = CGRectMake(0, 0, 150.0, 150.0);
[btn setImage:[self scaleAndRotateImage:[UIImage imageNamed:@"basicbutton.png"]] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
//add "stuff" to scrolling area
[scrollView addSubview:rowsBackground];
[scrollView addSubview:btn];
//add scrolling area to cocos2d
//this is just a UIWindow
[[[Director sharedDirector] openGLView] addSubview:scrollView];
//mem-mgmt
[rowsBackground release];
[btn release];
[scrollView release];