Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

drdos

macrumors newbie
Original poster
Sep 28, 2011
4
0
Hey Guys,

So I am working on an app here, I have a tableview that display's some comments in a social network app.

Apart of each cell inside the tableview I have built a custom cellview to display the data in the format I want.

I then add a subview of a custom UIView that I am building dynamically to that custom cell of the following class:

Code:
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@interface actionStatsBar : UIViewController{
    UIView *actionView;
}

@property(nonatomic, retain) UIView *actionView;

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

@end

Code:
#import "actionStatsBar.h"

@implementation actionStatsBar
@synthesize actionView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView{
    [super loadView];
   
    self.view.userInteractionEnabled = YES;
    self.view.bounds = CGRectMake(10, 60, 45.0, 20);
    self.view.clipsToBounds = YES;
    self.view.backgroundColor = [UIColor redColor];
    self.view.frame = CGRectMake(10, 60, 45.0, 20.0);
    
    self.view.layer.borderColor = [[UIColor blackColor] CGColor];
    self.view.layer.borderWidth = 1;
    
    
    
}


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
}
*/

- (void)viewDidUnload{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Touches Delagtes

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"enter touch");
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"enter finish touch");
}


@end

The problem is this:

When the table is loaded with the data and displaying the custom cells, the custom view is there, but when I click/press on that view its being over written by the TouchesBegan delegate on the custom cellview I have built.

Is there a way I can overwrite that - so when a user press/clicks on that custom view it will trigger the TouchesBegan event for that view and not the one inside the custom cell view?

Thanks
 
Nevermind I figured it out.

The isssue was inside my cellForRowAtIndexPath I was creating all the elements dynamically and when I was creating the custom UIView I was auto releasing it - so when I removed the autorelease it then worked.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.