0
iPadでテストすると、UILabelでUILongPressGestureRecognizer
に接続されたメソッドを正常に呼び出すことができます。アーカイブアプリケーションの後にUILongPressGestureRecognizerが動作しない
エンタープライズ展開のアプリケーションをアーカイブした後、UILongPressGestureRecognizerはもう機能しません。
@interface BGMSetMenuViewController : UIViewController <UIGestureRecognizerDelegate>
の.mファイルで:
は、私はすでに手動で.hファイルでUser Interaction Enabled:
をカチカチとは別に、次のコードを追加した同じを持ってここに
- (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とiOS 7 9で働いていた私はiOSの10.0.2でXcodeの8とテスト使用していることに注意してくださいと、それはもう動作しません。コードの下
ポストにも疑問を持つUILongPressGestureRecognizerのいくつかのコードをuserIntractionEnabledにラベルを付ける設定YES。 –
@JamshedAlam、私はいくつかのコードと説明を追加しました。 –
longPress.delegate = selfを設定しましたか? – user3182143