快速簡單的問題。我有一個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和寫一個簡單的圖像下載。
爲什麼不能ü設置按鈕的圖像popertyü一次取回您的異步形象? – Daniel 2011-01-05 15:26:23
當我嘗試訪問圖像屬性時,AsyncImageView的子視圖仍然爲空。所以圖像還不能訪問。 – Lewion 2011-01-05 15:35:39