すばやく簡単な質問です。私はUIButtonsのスクロールビューを持っています。ボタンはproductImageを表示する必要があります。これらの画像はWebサービスから来ているので、AsyncImageViewを使ってそれらをロードする必要があります。 AsyncImageViewをボタンのサブビューとして追加すると問題が発生するだけで、ボタンはもう押せなくなります。UIButtonの上にあるAsyncImageView
どうすればAsyncImageViewを押すことができますか?ボタンの後ろにAsyncImageViewを追加することはもちろん不可能です。
for (int i = 1; i < [searchResults2 count]; i++) {
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(((10*i) + ((i - 1)*90)), 40, 90, 90)];
[button setBackgroundColor:[UIColor whiteColor]];
[button setAlpha:0.9];
CGRect frame;
frame.size.width=90;
frame.size.height=90;
frame.origin.x=0;
frame.origin.y=0;
AsyncImageView* asyncImage = [[[AsyncImageView alloc] initWithFrame:frame] autorelease];
asyncImage.tag = 999;
[asyncImage loadImageFromURL:[NSURL URLWithString:[[searchResults2 objectAtIndex:(i-1)]
searchObjectImageUrl]]];
[button addSubview:asyncImage.view];
button.tag = i;
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:button];
}
ありがとうございます。
編集:AsyncImageviewを使用せず、画像用の簡単なダウンローダを作成して解決します。これはYESに設定userInteractionEnabledたzオーダーで次のオブジェクトに通過するasyncImageを「ヒット」という任意のタッチイベントを起こす必要がある
asyncImage.userInteractionEnabled = NO;
:
を使用することができますか? – Daniel
画像プロパティにアクセスしようとすると、AsyncImageViewのサブビューがまだ空になっているようです。したがって、画像にはまだアクセスできません。 – Lewion