【发布时间】:2016-01-09 12:01:44
【问题描述】:
我在viewDidLoad中拥有的是这个:
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(hideHeaderBar:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeUp.
[self.view addGestureRecognizer:swipeUp];
然后我在视图中有一个UIScrollView。出于某种原因,当我在滚动视图上向上滚动时,它不会调用选择 hideHeaderBar。有什么解决办法吗?
-(void)hideHeaderBar:(UISwipeGestureRecognizer*)swipeRecognizer{
POPSpringAnimation *fadeButton = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerOpacity];
fadeButton.toValue = @(0.0);
fadeButton.springBounciness = 0.f;
[settingsButton.layer pop_addAnimation:fadeButton forKey:@"fadeButton"];
[heartButton.layer pop_addAnimation:fadeButton forKey:@"fadeButton"];
[conversationsButton.layer pop_addAnimation:fadeButton forKey:@"fadeButton"];
POPSpringAnimation *hideHeader = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
hideHeader.toValue = @(-10);
hideHeader.springBounciness = 5.f;
[headerBar.layer pop_addAnimation:hideHeader forKey:@"hideHeaderAnim"];
POPSpringAnimation *hideBody = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame];
hideBody.toValue = [NSValue valueWithCGRect:CGRectMake(0, -10, screenSize.size.width, screenSize.size.height)];
hideBody.springBounciness = 5.f;
[homeScrollView.layer pop_addAnimation:hideBody forKey:@"hideBodyAnim"];
}
需要注意的一点是 UIScrollView 位于子视图控制器中(位于 UIScrollView 本身内)
[self addChildViewController:settingsViewController];
[homeScrollView addSubview:settingsViewController.view];
[settingsViewController.view setFrame:CGRectMake(0, 0, screenSize.size.width, screenSize.size.height)];
[settingsViewController didMoveToParentViewController:self];
【问题讨论】:
-
告诉我你的目标@(hideHeaderBar:)
-
==> 这是对您有帮助的帖子:- stackoverflow.com/questions/4407171/…
标签: ios objective-c uiscrollview uikit