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;
}
Highlighted
当我单击它时,likeButton不起作用。
如果关闭interactivePopGestureRecognizer
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
或改变likeButton.frame = CGRectMake(150, 150, 150, 50);
,likeButtonHighlighted
触摸工作正常。
我希望 likeButtonHighlighted
在使用时能正常工作interactivePopGestureRecognizer
。