2015-03-19 43 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; 
相關問題