2015-03-19 63 views
0

popViewController时使用interactivePopGestureRecognizer。button当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; 
} 

在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触摸工作。

我希望likeButton Highlighted正在使用时使用interactivePopGestureRecognizer

+0

是喜欢按键操作“'like'”上触摸类似按钮激发? – GoGreen 2015-03-19 12:04:04

+0

@GoGreen类似按钮在触摸时更改backgroundview。 – xx11dragon 2015-03-19 12:07:32

+0

当你设置self.navigationController.interactivePopGestureRecognizer.enabled = NO ;,是否像''开火的buton动作?请使用断点测试。 – GoGreen 2015-03-19 12:10:05

回答

0

现在已经晚了,但无论如何...这个解决方案为我工作:

self.navigationController.interactivePopGestureRecognizer.delegate = self; 
self.navigationController.interactivePopGestureRecognizer.cancelsTouchesInView = NO; 
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan = NO; 
self.navigationController.interactivePopGestureRecognizer.delaysTouchesEnded = NO; 
相关问题