UIButton on UIScrollView can't work

Posted by william-hu on Stack Overflow See other posts from Stack Overflow or by william-hu
Published on 2010-04-07T05:24:59Z Indexed on 2010/04/07 5:33 UTC
Read the original article Hit count: 594

Filed under:

Hi, i used

UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 180, 180)];
    myLabel.backgroundColor = [UIColor greenColor];
    [self.view addSubview:myLabel];

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [self addTarget:self action:@selector(show)  forControlEvents:UIControlEventTouchDown];
    myButton.frame = CGRectMake(80.0, 120.0, 30, 30);
    myButton.showsTouchWhenHighlighted = YES;
    [self addSubview:myButton];

in this way the button works(call show:), but use [myLabel addSubview:myButton]; the button can't work. who can tell me why? I have tried to change the target to myLabel, can't work too.So who can tell me,thank you.

By the way , i want to use the button on the UILabel,and the UILabel on UIScrollView.Thanks a lot!

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0