ios – 使用UIScreenEdgePanGestureRecognizer而不移动MKMapView

ios – 使用UIScreenEdgePanGestureRecognizer而不移动MKMapView,第1张

概述我有一个包含MKMapView的UIViewController(事实上,它包含一个包含MKMapView的全屏容器,但它不应该有任何影响) 我实现了一个UIScreenEdgePanGestureRecognizer(显示抽屉),如下所示: self.swipeRight = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:sel 我有一个包含MKMapVIEw的UIVIEwController(事实上,它包含一个包含MKMapVIEw的全屏容器,但它不应该有任何影响)

我实现了一个UIScreenEdgePanGestureRecognizer(显示抽屉),如下所示:

self.swipeRight = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleEdgeGesture:)];[self.swipeRight setEdges:UIRectEdgeleft];[self.swipeRight setDelegate:self];[self.vIEw addGestureRecognizer:self.swipeRight];

并使其工作我必须添加以下方法(返回YES):

(BOol)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;

但随后地图在抽屉出现的同时移动!
我已经尝试过各种各样的技巧来阻止它但是却无法……(我试过了例如shouldBerequiredToFailByGestureRecognizeror requireGestureRecognizerToFail)

有什么想法,当手势是来自leftEdge的ScreenEdgePan时,我怎么能阻止MapVIEw移动?

@H_419_15@解决方法 我在我的应用程序中所做的是以下内容:
UIScreenEdgePanGestureRecognizer *popRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePopRecognizer:)];popRecognizer.edges = UIRectEdgeleft;popRecognizer.delegate = self;

然后如你所说,将委托设置为YES

- (BOol)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{    return YES;}

并启用/禁用这样的mapvIEw滚动

- (voID)handlePopRecognizer:(UIScreenEdgePanGestureRecognizer*)recognizer{    if(recognizer.state == UIGestureRecognizerStateBegan){        _mapVIEw.scrollEnabled = NO;    } else if(recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled){        _mapVIEw.scrollEnabled = YES;    }}

希望能帮助到你.

@H_419_15@ @H_419_15@ 总结

以上是内存溢出为你收集整理的ios – 使用UIScreenEdgePanGestureRecognizer而不移动MKMapView全部内容,希望文章能够帮你解决ios – 使用UIScreenEdgePanGestureRecognizer而不移动MKMapView所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1109371.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存