- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
当用户使用 map View i 移动时,我想添加一些逻辑。 e.他做了一个平底锅触摸。但是当我添加手势识别器并且我想记录触摸时,什么也没有发生。当我在另一个 View Controller 中尝试它并将识别器添加到 Controller 的 View 中时,它可以正常工作。
这是我的代码( map View 是应用程序委托(delegate)的一个属性,因为即使它不可见,我也需要用它做一些其他事情):
- (void)viewDidLoad
{
...
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(showPan)];
[appDelegate.mapView addGestureRecognizer:panGesture];
[panGesture release];
}
- (void)showPan
{
NSLog(@"pan!");
}
我使用最新的 iOS 4.2.1
感谢您的建议。
最佳答案
好吧,因为没人知道,我不得不为此花费了一次 Apple 技术支持咨询。 ;o)
因为 MKMapView 显然有自己的识别器来与用户交互,所以你必须遵守 UIGestureRecognizerDelegate 协议(protocol)并像这样实现 (BOOL)gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
:
- (void)viewDidLoad
{
...
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(showPan)];
panGesture.delegate = self;
[appDelegate.mapView addGestureRecognizer:panGesture];
[panGesture release];
}
- (void)showPan
{
NSLog(@"pan!");
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
然后它就像一个魅力。
关于objective-c - MKMapView 上的 UIPanGestureRecognizer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5005597/
UIGestureRecognizer 的文档引用重置函数。 但是,在 UIPanGestureRecognizer(UIGestureRecognizer 的子级)上调用 reset() 会生成此错
我有一个 UIPanGestureRecognizer,它根据我的喜好检测了太多次。我需要一个计数器并计算 3 个已完成的手势。每次我用手指平移识别器位置时,它都会触发 3 到 4 次。甚至触发了5个
我正在使用 UIPanGestureRecogniser实现拖放。当拖动开始时,我需要识别被拖动的对象。但是对象相对较小。如果用户没有在对象的中心点击对象,它就不会被拖动。 问题是当手势处理程序第一次
我正在尝试使用UIPanGestureRecognizer实现页面翻转动画。这是代码: - (void)handlePan:(UIPanGestureRecognizer *)recognizer {
我有一个 UIView 子类,我在其中添加了一个 UIPanGestureRocognizer: _panGestureRecognizer = [[UIPanGestureRecognizer al
我试图使用 UIPanGestureRecognizer 来移动我的对象,但我似乎无法让它顺利移动。当我朝一个特定的方向移动并转向相反的方向时,它不会立即使用react。我认为该值可能有问题,因为它在
我正在尝试实现 View 的拖动,当拖动停止时, View 滑到顶部并消失。我可以使用 UIPanGestureRecognizer 很好地拖动 View 。但在那之后,我用动画让它滑出。问题是在拖动
我在touchesEnded方法中调用了一个名为addProjectile的方法。 addProjectile接收touchesEnded方法接收的触摸的NSSet。为简单起见,我仅将相关代码发布到我
我遇到了 UIPanGestureRecognizer 的问题。假设我使用不同的标签动态添加 10 个按钮,当我添加第一个按钮时,尝试将其拖动到其他位置,然后它就可以正常工作。然后,如果我添加其他按钮
我有一个基类,它处理单元格的一些基本动画。在我的子类中,我已经覆盖了识别器目标并想做一些其他事情,但翻译始终是 0 因为我在基类中调用翻译被重置为 .zero . 有没有办法让我的基类执行基本动画并使
我正在使用 UIPanGestureRecognizer 将图像拖出 UICollectionViewCell,然后查看它是否与屏幕上其他位置的另一个图像发生碰撞。为此,我需要能够匹配他们的翻译坐标。
我创建了一个UIPanGestureRecognizer,但问题是当我将 View 向右滑动时, View 会向左移动。 当我向左滑动 View 时,它会向右滑动。为什么? let panGestur
我正在开发一个类似于 Tinder 中的卡片 View 。当卡片X原点大于我声明的值时,它会移出屏幕。否则,它会再次粘在中心。我正在 UIPanGestureRecognizer 函数中执行所有这些操
我有一个 UIPanGestureRecognizer 附加到父 View ,带有各种 CCSprite 我想在平移时在父 View 中移动。使用 [gesture locationOfTouch:i
使用 UIPanGestureRecognizer 我们正在移动 UICollectionView 中的单元格 当我们开始拖动时 UIGestureRecognizerStateBegan 被调用。但
我有 6 个 UIImageView,每个都连接到 UIPanGestureRecognizer,它们都连接到相同的方法。方法是: - (IBAction)handlePan:(UIPanGestur
我是 swift 和 xcode 的新手。使用 xcode 10 并尝试制作一个类似应用程序的嗡嗡声,我需要在 View 中移动多个图像。我发现了很多关于 UIPanGestureRecognizer
我有一个侧面板,其中有一个 UIImageView,我在其中附加了一个 UIPanGestureRecognizer,以便您可以推/拉侧边栏。效果很好。 问题是我有一些按钮有时会出现在侧边栏下方。如果
本质上,我想做的是移动 View 以跟随用户的平移。只要使用相同的平移对象,这种方法就可以正常工作。当用户释放并启动另一个平移时,问题就出现了。 根据文档,translationInView 中的值是
我正在将 UIPanGestureRecognizer 添加到我的 View Controller 中的一个自定义 View 。 我还使用 MFSideMenu 作为滑动菜单,在其框架中将 UIPan
我是一名优秀的程序员,十分优秀!