I am programmatically creating buttons in a view inside UIScrollView
. I also have programmatically created UITextField
. I can select and enter data into the text fields all day long. But I cannot get any sign the buttons are being touched. I can add them to the main view and they work. But when added to the view inside the UIScrollView
, they are lost in another dimension. I've read plenty of info about setting userInteraction
, delayContentTouches
, and intercepting via gestureRecognizer
. The last might be related to my problem. I return NO
via [touch.view isDescendantOfView:self.myScrollViewName]
. I can't get it to trigger via [touch.view isKindOfClass:[UIButton class]]
. Which makes me think I have a more fundamental error I am missing?
related: https://stackoverflow.com/a/6825839/4050489
edited to add button code per request:
self.myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.myButton.frame = myButtonFrame;
self.myButton.enabled = interface.isActive;
self.myButton.userInteractionEnabled = YES;
self.myButton.exclusiveTouch = YES;
self.myButton.backgroundColor = [UIColor greenColor];
//self.myButton. = YES;
self.myButton.layer.borderWidth=1.0f;
self.myButton.layer.borderColor=[[UIColor blackColor] CGColor];
self.myButton.layer.cornerRadius = 10;
[self.myButton setTag:interface.tag];
[self.myButton setTitle:interface.Name forState:UIControlStateNormal];
[self.myButton addTarget:self action:@selector(navigatePartButtons:) forControlEvents:UIControlEventTouchUpInside];
[self.myButton setEnabled:YES]; //error check
[self.partSetupView addSubview:self.myButton];
partSetupView
is a UIView
in the UIScrollView
.