0

UILabel に追加されたボタンがあり、その UILabel が UIView に追加され、最後にその UIView がスクロール ビューに追加されました。

これは私のコードです:

nextBtn=[UIButton buttonWithType:UIButtonTypeCustom];
nextBtn.frame=CGRectMake(250, 8, 26, 26);           //2626
[nextBtn setImage:[UIImage imageNamed:@"disclosure1.png"] forState:UIControlStateNormal];
[nextBtn addTarget:self action:@selector(nextBtnClkd) forControlEvents:UIControlEventTouchUpInside];
[reviewLabel addSubview:nextBtn];
[middleView addSubview:reviewLabel];
[mScrollView addSubview:middleView];
[self.view addSubview: mScrollView];

これで、ボタンのクリック時に nextBtnClkd メソッドが呼び出されなくなりました。

私を助けてください。

ありがとう

ベン

4

3 に答える 3

2

ラベルと middleView コードを表示します。

nextBtn=[UIButton buttonWithType:UIButtonTypeCustom];
nextBtn.frame=CGRectMake(250, 8, 26, 26);
[nextBtn setImage:[UIImage imageNamed:@"disclosure1.png"] forState:UIControlStateNormal];
[nextBtn addTarget:self action:@selector(nextBtnClkd) forControlEvents:UIControlEventTouchUpInside];



[nextBtn addSubview:reviewLabel];  //Add label on Btn.  
[middleView addSubview:nextBtn];
[mScrollView addSubview:middleView];
[self.view addSubview: mScrollView];
于 2012-07-09T06:36:02.297 に答える
1

UILabel はインタラクション イベントを受け入れますか?

reviewLabel.userInteractionEnabled = YES;
于 2012-07-09T06:34:01.080 に答える
0

ラベルのユーザー インタラクションは NO に設定されています。最初に YES に設定します。

reviewLabel.userInteractionEnabled=YES;
于 2012-07-09T06:39:02.777 に答える