开发者

AsyncImageView on top of UIButton

Quick and simple question. I have a scrollview with UIButtons in it, these flip over when you press them. A button has to show a productImage. Because these images come from a webservice, I have to load them using an AsyncImageView. Only problem there is, when I add the AsyncImageView as a subview of the button, the button cannot be pressed anymore.

How can I press through the AsyncImageView? Adding the AsyncImageView behind the button is off course not an option.

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.si开发者_如何学JAVAze.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];
}   

Thanks in advance.

EDIT: Solved by not using AsyncImageview and writing a simple downloader for images.


Try this:

asyncImage.userInteractionEnabled = NO;

This should cause any touch events that "hit" the asyncImage to pass through to the next object in the z-order that has userInteractionEnabled set to YES.

-S


You can use following things

asyncImage.userInteractionEnabled = NO;
asyncImage.exclusiveTouch = NO;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜