2016-10-24 1 views
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とテスト使用していることに注意してくださいと、それはもう動作しません。コードの下

+0

ポストにも疑問を持つUILongPressGestureRecognizerのいくつかのコードをuserIntractionEnabledにラベルを付ける設定YES。 –

+0

@JamshedAlam、私はいくつかのコードと説明を追加しました。 –

+0

longPress.delegate = selfを設定しましたか? – user3182143

答えて

0

試してみてください。ストーリーボード

- (void)viewDidLoad { 
[super viewDidLoad]; 
labelTouch.userInteractionEnabled = YES; 
[self labelLongPressed:labelTouch];} 


- (void)labelLongPressed:(UILabel *)label{ 
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] 
            initWithTarget:self action:@selector(handleLongPress:)]; 
longPress.minimumPressDuration = 2; //seconds 
longPress.delegate = self; 
[label addGestureRecognizer:longPress];} 

-(void) handleLongPress : (UITapGestureRecognizer *)sender{ 
    UIButton *button = (UIButton *)sender.view; 
    NSLog(@"longpress");} 
関連する問題