0

Use interactivePopGestureRecognizer when popViewController.

Set Custom back button and keep 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;
}

have a likeButton on the 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 is not working when i clicked it.

If close interactivePopGestureRecognizer

self.navigationController.interactivePopGestureRecognizer.enabled = NO;

or change likeButton.frame = CGRectMake(150, 150, 150, 50);

,likeButton Highlighted touch is working.

i hope likeButton Highlighted is working when usedinteractivePopGestureRecognizer.

xx11dragon
  • 166
  • 1
  • 10

1 Answers1

0

It's late, but anyway... This solution works for me:

self.navigationController.interactivePopGestureRecognizer.delegate = self;
self.navigationController.interactivePopGestureRecognizer.cancelsTouchesInView = NO;
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan = NO;
self.navigationController.interactivePopGestureRecognizer.delaysTouchesEnded = NO;
aquarium_moose
  • 355
  • 1
  • 11