我正在尝试使用iOS8中的一个命令来启用滚动时隐藏导航栏的行为。
以下是代码
-(void)viewDidAppear:(BOOL)animated
{
self.navigationController.hidesBarsOnSwipe = YES;
}当快速向上滚动时,没有问题,因为导航栏将被向下拖动并自动可见。但是,即使我慢慢地滚动到顶部。导航栏不显示。
我试图通过使用scrollView委托来纠正这种行为。但这也不是很有效。因为动画看起来不太好。
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if(floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_8_0)
{
float scrollOffset = scrollView.contentOffset.y;
if (scrollOffset < 10)
{
self.navigationController.navigationBarHidden = NO;
}
}
}请帮帮忙。我想尽可能简单地做这件事。提前感谢
发布于 2015-12-06 00:25:04
要显示何时到达顶部,请使用以下命令
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.row == 0 {
self.navigationController?.hidesBarsOnSwipe = false
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
else {
self.navigationController?.hidesBarsOnSwipe = true
}发布于 2018-06-15 17:46:48
我刚刚遇到了同样的问题。
当我使用UINavigationController的hidesBarsOnSwipe属性时。我不能在滚动/滑动中再次显示它。在我的例子中,我使用的是UIScrollView,而scrollview的顶部是Aling to SafeArea.Top
我刚刚把scrollview的顶层改成了SuperView.Top,
its。
谢谢。
发布于 2017-06-06 23:28:55
我有一个在顶部有正确约束的UIScrollView,但它的行为仍然很奇怪。
我是这样解决的:
-(void)scrollViewDidScroll: (UIScrollView*)scrollView
{
float scrollViewHeight = scrollView.frame.size.height;
float scrollContentSizeHeight = scrollView.contentSize.height;
float scrollOffset = scrollView.contentOffset.y;
if (scrollOffset < 0)
{
self.navigationController.hidesBarsOnSwipe = NO;
[self.navigationController setNavigationBarHidden:NO animated: YES];
}
else
{
self.navigationController.hidesBarsOnSwipe = YES;
}
}https://stackoverflow.com/questions/32992897
复制相似问题