我将子视图添加到a UIScrollView,然后我添加UIPanGestureRecognizer到这些子视图.一切正常但现在添加UIPanGestureRecognizer到滚动视图的子视图后,滚动是不可能的.
这个问题的可能解决方案是什么?
我使用以下代码将UIPanGuestureRecognizer添加到整个视图中:
UIPanGestureRecognizer *pgr = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
[[self view] addGestureRecognizer:pgr];
Run Code Online (Sandbox Code Playgroud)
在主视图中我有一个UITableView,其中包含此代码以启用滑动删除功能:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"RUNNING2");
return UITableViewCellEditingStyleDelete;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row >= _firstEditableCell && _firstEditableCell != -1)
NSLog(@"RUNNING1");
return YES;
else
return NO;
}
Run Code Online (Sandbox Code Playgroud)
仅RUNNING1打印到日志,并且"删除"按钮不会显示.我相信其原因是UIPanGestureRecognizer,但我不确定.如果这是正确的,我该如何解决这个问题.如果这不正确,请提供原因并解决.谢谢.
目前,我正在构建一个应用程序,其中包含使用 UIPanGestureRecognizer 的功能。之前,我使用的是 Intel Mac,UIPanGestureRecognizer速度属性工作正常并返回预期值。然而,当我切换到MacBook M1后,panGesture的速度总是返回0。
@objc
func panGesture(_ recognizer: UIPanGestureRecognizer) {
view.endEditing(true)
let translation = recognizer.translation(in: self.view)
let velocity = recognizer.velocity(in: self.view)
// The velocity should have a value when a gesture is happening
//.....
} // End of PanGesture
Run Code Online (Sandbox Code Playgroud)
是否有任何补丁或某些操作可以使其正常工作,与英特尔芯片相同?我希望得到一些解决该问题的建议。
仅供参考:在真实设备上测试该应用程序,它仍然工作正常。
我在一个透明的UIView下有一个UIScrollView.我需要将所有平移和点击转移到滚动视图(仅水平滚动).常规UIView使用UIPanGestureRecognizer的子类来跟踪垂直平移(此处找到的子类).在覆盖视图中,我覆盖触摸事件方法以将它们传递给UIScrollView.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesBegan:touches withEvent:event];
[self.scrollView.singleTapGesture touchesBegan:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesCancelled:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesCancelled:touches withEvent:event];
[self.scrollView.singleTapGesture touchesCancelled:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesEnded:touches withEvent:event];
[self.scrollView.singleTapGesture touchesEnded:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesMoved:touches withEvent:event];
[self.scrollView.singleTapGesture touchesMoved:touches withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)
叠加视图,垂直平移工作完美.在UIScrollView中,水龙头也可以完美运行.滚动但不是那么多.滚动视图滚动大约三个点,然后停止(因为我继续使用水平平移.)如果我放开速度,滚动视图然后选择该速度并完成滚动.
导致滚动视图停止滚动然后获取速度的可能问题是什么?
我正在尝试向包含滚动视图的视图添加平移手势识别器,但我想我的优先级问题.
我的全局UIView有一个UIPanGestureRecognizer设置如下:
_bottomPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(bottomPanGestureDetected:)];
_bottomPanGestureRecognizer.minimumNumberOfTouches = 2;
_bottomPanGestureRecognizer.maximumNumberOfTouches = 2;
_bottomPanGestureRecognizer.delaysTouchesBegan = NO;
_bottomPanGestureRecognizer.delaysTouchesEnded = NO;
Run Code Online (Sandbox Code Playgroud)
我想要识别这个手势,从底部显示另一个视图,并进行一些向下的捏合.
问题是scrollview在我之前识别它自己的平移手势.
所以我试图推迟它,这要归功于:
[_scrollView.panGestureRecognizer requireGestureRecognizerToFail:_bottomPanGestureRecognizer];
Run Code Online (Sandbox Code Playgroud)
并且它正常工作,滚动视图事件在我的两个手指向上到识别器之后被触发,但问题是现在当我只使用一个手指在滚动视图中滚动时,滚动在一小段延迟之后工作.
我想对此次活动没有任何延误,这可能吗?欢迎任何想法!
干杯.
西里尔
我想在两个视图控制器之间实现交互式转换.我希望它是一个模态或现在的过渡.
我知道我需要使用以下内容.
transitioningDelegate
animationController(forPresented:呈现:来源:)
interactionControllerForPresentation(使用:)
UIPercentDrivenInteractiveTransition
我无法弄清楚如何实现这一切.我似乎无法在swift 3中找到任何有用的或任何有用的示例.现在我创建了一个简单的单视图应用程序,其中包含两个视图控制器VC1(蓝色背景)和VC2(黄色背景),以便轻松测试任何可能的解决方案.
我正在研究如何在 React Native 中检测手指移动到视图中。例如,我在屏幕中有一个视图。我的手指按在视图外,然后慢慢移动到视图。当手指越过边界时,视图可以识别我的手指。
我研究了Gesture Responder和PanResponder。但是我发现的所有示例都涉及视图并移动它。
如果您有办法或示例代码来执行我上面所说的操作,请告诉我。
我需要做一些数学计算才能到达目的地吗?
先感谢您!
android uigesturerecognizer ios uipangesturerecognizer react-native
我有类似的问题,如下面的链接
但是,这个链接也没有解决我的问题.我正在为同一个UIImage使用平移,捏合和旋转手势.当我旋转该图像并执行平移时,它将进行随机平移(有时它会在平移的相反方向上进行.我还将锚点设置为(0.5,0.5)).但是,如果我只使用平移(即旋转前),它将表现良好.我该如何解决这个问题?
我有一个UIScrollView包含许多子视图的视图。子视图之一设计为显示折线图,因此用户可能需要水平拖动。事实是,当我要水平拖动手指时,UIScrollView很容易激活的垂直滚动。现在,我想在图表的子视图中禁用垂直滚动,并在其余部分中将其保持活动状态。
我试图将一个添加UIPanGestureRecognizer到我的图表子视图。它确实禁用了垂直滚动,但水平滚动也被禁用。我知道我可以在手势识别器的处理程序中编写代码来告诉我所需的垂直或水平滚动。但是水平滚动实际上是由子视图的控制器管理的,该控制器是第三方库(JBChartView具体来说)。我想知道是否有解决此问题的简单方法。
非常感谢。
我的设置
我正在尝试复制Google Now的卡界面.
我有一个UIView(内部)a的子视图UIScrollView.两者都是相同的UIViewController.该UIView有一个UIPanGestureRecognizer被连接到它UIViewController.
将UIScrollView用于向上和向下滚动.该UIPanGestureRecognizer用于滑开UIView.
问题
当我触摸UIView(卡片)时我无法滚动
问题
如何实现在卡UIGestureRecognizerDelegate上启用gestureRecognizer(_:shouldRecognizeSimultaneouslyWithGestureRecognizer:)以便它可以UIScrollView滚动?
我花了几个小时试图解决这个问题,我非常感谢你的帮助.
ios ×7
uiscrollview ×5
objective-c ×3
swift ×3
uiview ×2
android ×1
apple-m1 ×1
iphone ×1
react-native ×1
swift3 ×1
uitableview ×1