When testing in iPad, I can successfully call the method attached to UILongPressGestureRecognizer
in UILabel.
After I have archived the application for Enterprise deployment, UILongPressGestureRecognizer does not work anymore.
I have already added the following codes aside from manually ticking User Interaction Enabled:
In .h file:
@interface BGMSetMenuViewController : UIViewController <UIGestureRecognizerDelegate>
In .m file:
- (void)viewDidLoad
{
[super viewDidLoad];
itemPriceLabel.userInteractionEnabled = YES;
itemNameLabel.userInteractionEnabled = YES;
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressSetMenuPrice:)];
longPress.delegate = self;
[itemPriceLabel addGestureRecognizer:longPress];
}
#pragma mark - UILongPressGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
- (void)longPressSetMenuPrice:(UILongPressGestureRecognizer*)gesture
{
if (gesture.state == UIGestureRecognizerStateEnded) {
BGMPasscodeViewController *passcodeVC = [[BGMPasscodeViewController alloc] initWithNibName:@"BGMPasscodeViewController" bundle:nil];
self.providesPresentationContextTransitionStyle = YES;
self.definesPresentationContext = YES;
[passcodeVC setModalPresentationStyle:UIModalPresentationOverCurrentContext];
[self presentViewController:passcodeVC animated:YES completion:nil];
}
}
Anybody here who have the same experience?
Please note that this was working in Xcode 7 and iOS 9.
Now, I'm using Xcode 8 and testing in iOS 10.0.2 and it doesn't work anymore.