如何在iOS 8(如Lyft应用程序)上隐藏MKMapView上的UINavigationItem平移手势?

如何在iOS 8(如Lyft应用程序)上隐藏MKMapView上的UINavigationItem平移手势?,ios,objective-c,uiscrollview,uinavigationcontroller,mkmapview,Ios,Objective C,Uiscrollview,Uinavigationcontroller,Mkmapview,您好,谢谢您查看此问题 我试图模仿Lyft应用程序的功能 在Lyft应用程序中,当用户在地图上平移时,底部栏和顶部的UINavigationBar都会消失。我正在尝试在自己的应用程序中重新创建此功能 在iOS 8上,UINavigationController上有一个属性,可用于隐藏滚动条上的顶部栏。这很好,但是同样的功能可以在mapview pan上实现吗 另外,在我的应用程序中,我有一个UITabBar。有人知道如何隐藏它吗???将平移手势添加到mapview并设置代理 UIPanGest

您好,谢谢您查看此问题

我试图模仿Lyft应用程序的功能

在Lyft应用程序中,当用户在地图上平移时,底部栏和顶部的UINavigationBar都会消失。我正在尝试在自己的应用程序中重新创建此功能

在iOS 8上,UINavigationController上有一个属性,可用于隐藏滚动条上的顶部栏。这很好,但是同样的功能可以在mapview pan上实现吗


另外,在我的应用程序中,我有一个UITabBar。有人知道如何隐藏它吗???

将平移手势添加到mapview并设置代理

UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
pan.delegate = self;
[self.mapView addGestureRecognizer:pan];
执行手势委托并返回YES

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}
手势选择器

-(void)pan:(UIPanGestureRecognizer*)ges
{
    [self.navigationController setNavigationBarHidden:1 animated:1];
    [self.tabBarController.tabBar setHidden:YES];
}

MKMapView的这些委托方法看起来也非常有用!这很好,因为您很可能已经实现了MKMapView委托

- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
然后你可以躲起来

[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.tabBarController.tabBar setHidden:YES];
并打开隐藏

[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.tabBarController.tabBar setHidden:NO];