Note that there are some explanatory texts on larger screens.

plurals
  1. POTapping on image i m getting EXC_BAD_ACCESS
    primarykey
    data
    text
    <p>Guys, i thought i found the solution but no.... i making app cont. from past 16 hrs, may be that's y my empty mind is not making any good sound... plz help me..</p> <p>I am setting Tag to my dynamically generated imageviews and setting tapgestureReconizers on that,tags are given to UITapGestureRecognizer, i want to perform different actions on click on different images, but when ever click on any image it says very silently... :| EXC_BAD_ACCESS. Code: -</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @class AppDelegate_iPhone,Litofinter,ParsingViewController; @interface FirstViewController : UIViewController&lt;UIGestureRecognizerDelegate&gt;{ NSMutableArray *array; NSString *logoString; AppDelegate_iPhone *appDelegate; ParsingViewController *obj; UIScrollView *scrollView; NSMutableArray *idArray; } @property (nonatomic,retain)UIScrollView *scrollView; -(void)onTapImage:(UITapGestureRecognizer *)recognizer; @end #import "FirstViewController.h" #import "AppDelegate_iPhone.h" #import "Litofinter.h" #import "ParsingViewController.h" @implementation FirstViewController @synthesize scrollView; -(id)init{ if(self == [super init]){ obj = [[ParsingViewController alloc] init]; array = [[NSArray alloc] initWithArray: obj.LogoMutableArray]; } return self; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; int x=20,y=10; int a=50,b=105; appDelegate = (AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate]; scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0,500, 460)]; scrollView.contentSize = CGSizeMake(320,800); scrollView.showsVerticalScrollIndicator = YES; for (Litofinter *lito in appDelegate.logoArray) { NSString * urlString = [lito.cLogo stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; NSURL * imageURL = [NSURL URLWithString:urlString]; NSData * imageData = [NSData dataWithContentsOfURL:imageURL]; UIImage * image = [UIImage imageWithData:imageData]; UIImageView *imgView = [[UIImageView alloc] initWithImage:image]; [imgView setFrame:CGRectMake(x, y, 140, 90)]; imgView.userInteractionEnabled = YES; imgView.multipleTouchEnabled = YES; imgView.backgroundColor = [UIColor blueColor]; // imgView.tag = lito.cId; // NSLog(@"Tag Id = %@",imgView.tag); NSLog(@"Tag Id = %@",lito.cId); UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapImage:)]; tgr.delegate = self; [imgView addGestureRecognizer:tgr]; [scrollView addSubview:imgView]; tgr.view.tag =(int)[NSString stringWithFormat:@"%@",lito.cId]; NSLog(@"Tag Id = %@",tgr.view.tag); // NSLog(@"Tag Id = %@",lito.cId); UILabel *cName = [[UILabel alloc]initWithFrame:CGRectMake(a, b, 130, 20)]; cName.text = lito.cName; [scrollView addSubview:cName]; //Do the rest of your operations here, don't forget to release the UIImageView x = x + 150; a = a + 140; if(x &gt;300) { y = y +140; x = 20; b = b +150; a = 50; } //[tgr release]; [imgView release]; } [self.view addSubview:scrollView]; } -(void)onTapImage:(UITapGestureRecognizer *)recognizer; { NSLog(@"Tapped Image tag: %@", recognizer.view.tag); //NSLog(@"Tapped Image Id ======================== %@",scrollView.gestureRecognizers); UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Message from mAc" message:[NSString stringWithFormat:@"Tag Id : %@",recognizer.view.tag] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil]; [alert show]; } - (void)dealloc { [super dealloc]; [scrollView release]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload