how to change image on tap in table view for iphone -
I have an image view in the table cell, how do I now have to touch the image on the image how to do it
switch (indexPath.section) case 0: CGR frame; Frame = CGRactam (20, 10, 270, 180); // 277 182 UIMviewview * IIMAJview = [[UIMAge Week Alok] IIT]; MyImageView.image = [UIImage imageNamed: @ "Abe1.jpg"]; // abe2, abe3.png myImageView.frame = frames; // UIImageView * imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "bowl.png"]]; [Cell.contentView addSubview: myImageView]; [MyImageView release];
How to change the image on the tap (abe1.png, abe2.png, abe3.png) ??
You need to do the following:
// Will check whether the user started touching something - (zero) touches the brinze: (NSSet *) touches the event: (UIEvent *) event {UIT * touch = [touches any object]; // Checks that the user has touched your image if ([[Touch View] == myImageView) {// Create an integer that will keep track of your image Start at zero for Abe1 if (counter == 0 ) {MyImageView.image = [UIImage imageNamed: @ "Abe2.jpg"]; Counter = 1; } And if (counter == 1) {myImageView.image = [UIImage imageNamed: @ "Abe3.jpg"]; Counter = 2; } And if (counter == 2) {myImageView.image = [UIImage imageNamed: @ "Abe1.jpg"]; Counter = 0; }}}
Edit:
Sorry, I forgot that this was the table view. To check whether the correct cell performs the following:
- (zero) table view: (UITableView *) Select TableView Disclaimer: (NSIndexPath *) Index Pathway {NsiInteger Row = [Index Line]; If (line == 0) {if (counter == 0) {myImageView.image = [UIImage imageNamed: @ "Abe2.jpg"]; Counter = 1; } And if (counter == 1) {myImageView.image = [UIImage imageNamed: @ "Abe3.jpg"]; Counter = 2; } And if (counter == 2) {myImageView.image = [UIImage imageNamed: @ "Abe1.jpg"]; Counter = 0; }}
Comments
Post a Comment