• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
User interface items not get touch events in custom view in iOS app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

User interface items not get touch events in custom view in iOS app


  • Subject: User interface items not get touch events in custom view in iOS app
  • From: talesp <email@hidden>
  • Date: Mon, 20 Jun 2011 14:10:33 +0000 (GMT)

Hi,

I have a custom view if a few buttons in it. These buttons are added to the view programatically in initWithFrame method:

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        btnGlass = [UIButton buttonWithType:UIButtonTypeCustom];
        btnGlass.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, 30, 30);
        [btnGlass addTarget:self action:@selector(toggleGlass) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btnGlass];
        
        btnDia = [UIButton buttonWithType:UIButtonTypeCustom];
        btnDia.frame = CGRectMake(self.frame.size.width - 30, self.frame.origin.y + 35, 30, 30);;
        [btnDia addTarget:self action:@selector(setDiario) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btnDia];
        
        btnSemana = [UIButton buttonWithType:UIButtonTypeCustom];
        btnSemana.frame = CGRectMake(self.frame.size.width - 30, self.frame.origin.y + 66, 30, 30);;
        [btnSemana addTarget:self action:@selector(setSemanal) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btnSemana];
...

- (void)toggleGlass {
    NSLog(@"%s", __FUNCTION__);
...
}

- (void)setDiario {
    NSLog(@"%s", __FUNCTION__);
...
}

- (void)setSemanal {
    NSLog(@"%s", __FUNCTION__);
...
}

The view controller has a UIScrollview, and the above custon view is added programatically to this scroll view in the loadView method:

- (void)loadView {
    [super loadView];
    nextComponentPosition = self.view.frame.origin;
    [scrollTestComponents setScrollEnabled:YES];
    [scrollTestComponents setCanCancelContentTouches:NO];
    [scrollTestComponents setBackgroundColor:[UIColor blackColor]];
    scrollTestComponents.clipsToBounds = YES;
    scrollTestComponents.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    [self createGraphView];
}

- (void)createGraphView {
    self.graphView = [[ECGraphView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, 320, 214.7)];
    [graphView setDelegate:self];
    [scrollTestComponents setContentSize:CGSizeMake(320, 214.7)];
    [scrollTestComponents addSubview:self.graphView];
...

In this case, the buttons btnGlass and btnDia work as expected, calling the correspondent method, but btnSemana doesn't work. Even when the button types are rounded rect, the first two buttons change color as they are touched, but btnSemana doesn't behave like this.

Does someone know what I doing wrong?

Thank you._______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: How to redraw a view in slow-motion
  • Next by Date: Re: Use kAERestart to Restart Computer
  • Previous by thread: Re: NSSavePanel called from 64-bit NPAPI plugin
  • Next by thread: Agent that displays a window with textbox
  • Index(es):
    • Date
    • Thread