tags:

views:

26

answers:

1

I created a custom AQGridViewCell.

By using UIImageView everything works. The image appears and is clickable, but when I change the UIImageView to TTImageView I can't click on the image.

The same example as here below by just changing the imageview to UIImageView and the the setter message to an image, everything works as expected.

Here is my ImageGridCell.h

#import "AQGridViewCell.h"
#import <Three20/Three20.h>

@interface ImageGridCell : AQGridViewCell
{
    TTImageView * _imageView;
 NSString *urlPath;
}
@property (nonatomic, retain) NSString *urlPath;

@end

And here is my ImageGridCell.m

#import "ImageGridCell.h"

@implementation ImageGridCell
@synthesize urlPath;

- (id) initWithFrame: (CGRect) frame reuseIdentifier: (NSString *) aReuseIdentifier
{
    self = [super initWithFrame: frame reuseIdentifier: aReuseIdentifier];
    if ( self == nil )
        return ( nil );

    _imageView = [[TTImageView alloc] initWithFrame: CGRectMake(0, 0, 100, 100)];
 [_imageView setContentMode:UIViewContentModeScaleAspectFit];
    [self.contentView addSubview: _imageView];
    return ( self );
}

- (void) dealloc
{
    [_imageView release];
    [super dealloc];
}

- (CALayer *) glowSelectionLayer
{
    return ( _imageView.layer );
}

- (UIImage *) image
{
    return ( _imageView.image );
}
-(void)setUrlPath:(NSString *)urlpath {
 _imageView.urlPath = urlpath;
}
A: 

Not quite sure what you mean by "clickable" - like a UIButton? What behavior do you want to accomplish when a user taps one of the images?

I can't see the immediate problem here, but I can give you information that may help.

Foremost, TTImageView and UIImageView both descend from UIView, TTImageView does not descend from UIImageView (important to note):

UIImageView : UIView
TTImageView : TTView : UIView

We don't know what is going on behind the scenes in UIImageView, so I can't see what is different there, but the documentation seems to make clear that the UIImageView's default behavior for userInteractionEnabled is NO - which is odd, because you are saying that it is working with UIImageView, not the other way around.

Have you tried setting the userInteractionEnabled property to YES on TTImageView?

phooze
Thanks for your answer. AQGridView has a method like TableView where if you click on the "item" you get a notification. I don't get this notification to the AQGridView Delegate. I have tried both resign firstrepsonder and set userinteraction enabled to YES.
Trausti Thor Johannsson
Maybe it's better to see the code in the AQGridView, then, where the notification is generated... that may be helpful.
phooze