0
在iPad中測試時,我可以成功調用UILabel中UILongPressGestureRecognizer
附帶的方法。UILongPressGestureRecognizer無法在歸檔應用程序後工作
在我將Enterprise應用程序存檔歸檔後,UILongPressGestureRecognizer不再工作。
我已經添加以下代碼除了手動滴答User Interaction Enabled:
在.h文件中:
@interface BGMSetMenuViewController : UIViewController <UIGestureRecognizerDelegate>
在.m文件:
- (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];
}
}
要是誰具有相同經驗?
請注意,這是在Xcode 7和iOS 9
工作現在,我使用的Xcode 8和測試iOS版10.0.2,它不工作了。
後UILongPressGestureRecognizer的一些代碼的問題。 –
@JamshedAlam,我添加了一些代碼和解釋。 –
您是否設置了longPress.delegate = self? – user3182143