我实现了一个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所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)