2015-03-19 1 views
0

Используйте interactivePopGestureRecognizer, когда popViewController.кнопка Выделенная не работает, когда interactivePopGestureRecognizer.enabled = YES

Установите пользовательскую кнопку возврата и сохраните файл interactivePopGestureRecognizer = YES.

- (void)setNavigation { 
    [self.navigationController.scrollNavigationBar setNavigationTitleColor:[UIColor whiteColor]]; 

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] 
                   style:UIBarButtonItemStyleDone 
                   target:self 
                   action:@selector(popViewController)]; 
    backButton.tintColor = [UIColor whiteColor]; 
    self.navigationItem.leftBarButtonItem = backButton; 

    self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self; 
} 

У вас естьButton на ViewController.

- (YMFeedLikeButton *)likeButton { 
if (!_likeButton) { 
    YMFeedLikeButton *likeButton = [[YMFeedLikeButton alloc] init]; 
     replyButton.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height - 50, 150, 50); 
    [likeButton setImage:[UIImage imageNamed:@"topic-icon-like.png"] 
       forState:UIControlStateNormal]; 
    [likeButton setImage:[UIImage imageNamed:@"topic-icon-like.png"] 
       forState:UIControlStateNormal | UIControlStateHighlighted]; 
    [likeButton setImage:[UIImage imageNamed:@"topic-icon-liked.png"] 
       forState:UIControlStateSelected]; 
    [likeButton setImage:[UIImage imageNamed:@"topic-icon-liked.png"] 
       forState:UIControlStateSelected|UIControlStateHighlighted]; 

    UIImage *highlight = [UIImage imageNamed:@"highlight.png"]; 
    [likeButton setBackgroundImage:highlight 
          forState:UIControlStateHighlighted | UIControlStateSelected]; 
    [likeButton setBackgroundImage:highlight 
          forState:UIControlStateHighlighted | UIControlStateNormal]; 
    [likeButton setBackgroundImage:highlight 
          forState:UIControlStateHighlighted]; 

    [likeButton addTarget:self action:@selector(like) 
     forControlEvents:UIControlEventTouchUpInside]; 
    [likeButton setTitleColor:[UIColor colorWithRed:170.0f/255.0f green:170.0f/255.0f blue:170.0f/255.0f alpha:1.0f] 
        forState:UIControlStateNormal]; 
    [likeButton setTitleColor:[UIColor colorWithRed:170.0f/255.0f green:170.0f/255.0f blue:170.0f/255.0f alpha:1.0f] 
        forState:UIControlStateSelected]; 
    [likeButton setImageEdgeInsets:UIEdgeInsetsMake(0, -30, 0, 0)]; 
    likeButton.value = 0; 
    [self insertSubview:_likeButton = likeButton atIndex:0]; 
} 
return _likeButton; 

}

likeButton Highlighted не работает, когда я нажал ее.

Если близко interactivePopGestureRecognizer

self.navigationController.interactivePopGestureRecognizer.enabled = NO; 

likeButton.frame = CGRectMake(150, 150, 150, 50); или изменить

, likeButton Highlighted сенсорный работает.

я надеюсь, чтоButton Highlighted работает если используется interactivePopGestureRecognizer.

+0

является как действие кнопки «' like'»обстрелял касанием кнопки, как? – GoGreen

+0

@GoGreen как кнопка изменения фонового изображения при касании. – xx11dragon

+0

когда вы устанавливаете self.navigationController.interactivePopGestureRecognizer.enabled = NO ;, это действие бутона 'like' уволено? пожалуйста, проверьте с помощью контрольной точки. – GoGreen

ответ

0

Это поздно, но все равно ... Это решение работает для меня:

self.navigationController.interactivePopGestureRecognizer.delegate = self; 
self.navigationController.interactivePopGestureRecognizer.cancelsTouchesInView = NO; 
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan = NO; 
self.navigationController.interactivePopGestureRecognizer.delaysTouchesEnded = NO; 

 Смежные вопросы

  • Нет связанных вопросов^_^