Note that there are some explanatory texts on larger screens.

plurals
  1. POTouches Began method not called in my custom class
    primarykey
    data
    text
    <p>In my view of my iPhone app, I have added one sub view, which is a custom class. I have .h and .m file for this custom class which inherits from Image View.</p> <p>The problem is that touches began method of my viewcontroller is called, rather than the custom class's touches began method.</p> <p>What I am thinking is when I touch this <code>image class view</code> in my view:</p> <pre><code>/* Assign Categories */ Category *category1=[[Category alloc] initWithName:[[categoriesMArray objectAtIndex:0] valueForKey:@"category_name"] identity:[[[categoriesMArray objectAtIndex:0] valueForKey:@"category_id"] intValue] imageName:[[categoriesMArray objectAtIndex:0] valueForKey:@"category_image"]]; [category1 setFrame:CGRectMake(10,10, 150, 150)]; Category *category2=[[Category alloc] initWithName:[[categoriesMArray objectAtIndex:1] valueForKey:@"category_name"] identity:[[[categoriesMArray objectAtIndex:1] valueForKey:@"category_id"] intValue] imageName:[[categoriesMArray objectAtIndex:1] valueForKey:@"category_image"]]; [category2 setFrame:CGRectMake(170,10, 150, 150)]; NSLog(@"Categories %@",category3.imageName); [self.view addSubview:category1]; [self.view addSubview:category2]; [self.view bringSubviewToFront:category1]; </code></pre> <p>it should call my custom class portion:</p> <pre><code>@implementation Category @synthesize categoryName,categoryID,imageName; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } - (id)initWithName:(NSString *)name identity:(int)index imageName:(NSString *)imgName { if ((self = [super init])) { self.categoryName = name; self.categoryID =index; self.imageName=imgName; UIImage *temptoResize=[UIImage imageNamed:self.imageName]; [super setImage:[temptoResize scaleToSize:CGSizeMake(200, 150)]]; } return self; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Category Touch %@",self.frame); } </code></pre> <p>//------------------------</p> <p><code>-touchesBegan method</code> of my <strong>custom class</strong> rather than of my <strong>view Controller's</strong>.</p> <p>Please tell me why my custom class method is not called.</p>
    singulars
    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