0

iPad でテストするとUILongPressGestureRecognizer、UILabel にアタッチされたメソッドを正常に呼び出すことができます。

エンタープライズ展開用にアプリケーションをアーカイブした後、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 でテストしていますが、動作しません。

4

1 に答える 1