My goal is to simply send the correct button.titleLabel.text
to the handleLongPress function of my view controller. This is my function:
- (IBAction)handleLongPress:(UILongPressGestureRecognizer *)sender {
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 1.0;
[self setUserIntendsToChangeUIsoTheUIisLockedUntilUserSelection:YES];
NSLog(@"sender? %@", sender);
if ([sender.view isKindOfClass:[UIButton class]]) {
self.myButton = (UIButton *)sender.view;
NSLog(@"!!!!! %@", self.myButton.titleLabel.text);
[self.view addSubview:self.scrollPickerView];
}
}
This is my storyboard of which I have created a referencing outlet collection of buttons "H", "Cl", "C" etc etc.
Each button does respond to the UILongPressGesture
, however the logged message NSLog(@"!!!!! %@", self.myButton.titleLabel.text);
always references the same UIButton "C", even if I hold a different button. What have I done wrong? How can I get each button to send its title to the handleLongPress function?