I Place the imgaes as below.
In ListView.m
-(void)viewDidLoad()
{
int j=5;
for (int i=0; i<[po_id_array count]; i++) {
ViewForTickImage *tickimage=[[ViewForTickImage alloc]initWithFrame:CGRectMake(5, j, 35, 35)];
NSLog(@"----------%d",j);
j=j+17;
[tickimage setTick:FALSE];
[tickimage setTag:i];
// [tickimage setDelegate:self];
[self.view addSubview:tickimage];
}
}
In ViewForTickImage.h file the code is as follows:
@interface ViewForTickImage : UIView
{
BOOL ticked;
NSMutableArray *list_selected;
id delegate;
UIImageView *currentImg;
AppDelegate *appdelegate;
}
//@property(nonatomic,readwrite)BOOL ticked;
@property(nonatomic,readwrite,getter=isTicked,setter=setTick:)BOOL ticked;
@property(nonatomic,retain) UIImageView *currentImg;
-(void)checkTickVisiblilityForListAllView;
In ViewForTickImage.m file the code is::
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
currentImg = [[UIImageView alloc]initWithFrame:frame];
[currentImg setContentMode:UIViewContentModeScaleAspectFit];
UIImage *img=[UIImage imageNamed:@"image_unselect.png"];
[currentImg setImage:img];
[self addSubview:currentImg];
}
return self;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"image selected");
}
It displays the column of images.Touch event is working only for first image.How to fire the touch event for all images.Please give the solution.
Instead of using imageView try using UIbutton and add image to the image property of the button. yoU can identify the click in a simple way.
Using tag property of the button you can identify which button was clicked.