popViewController时使用interactivePopGestureRecognizer。
设置自定义后退按钮并保持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;
}
在ViewController上有一个likeButton。
- (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
触控正在发挥作用。
我希望在使用Highlighted
时,喜欢按钮interactivePopGestureRecognizer
正在使用。
答案 0 :(得分:0)
已经很晚了,但无论如何......这个解决方案适合我:
self.navigationController.interactivePopGestureRecognizer.delegate = self;
self.navigationController.interactivePopGestureRecognizer.cancelsTouchesInView = NO;
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan = NO;
self.navigationController.interactivePopGestureRecognizer.delaysTouchesEnded = NO;