我正在开发一个应用程序,我使用了Pan Gesture以及Swipe Gesture.因此,每次我执行Swipe Gesture时,Pan手势中的方法总是被调用,并且Swipe Gesture方法不会被调用.
所有的手势方法之间有没有优先权?
iphone uigesturerecognizer ios uiswipegesturerecognizer uipangesturerecognizer
我试图在iPad上的iOS 8中设置边缘滑动手势但是获取和错误似乎是一个错误.
我有以下代码:
UIScreenEdgePanGestureRecognizer *edgeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleRightEdgeSwipe:)];
edgeRecognizer.edges = UIRectEdgeRight;
[self.view addGestureRecognizer:edgeRecognizer];
Run Code Online (Sandbox Code Playgroud)
然后我处理手势:
-(void)handleRightEdgeSwipe:(UIGestureRecognizer*)sender
{
//slide in view code here
}
Run Code Online (Sandbox Code Playgroud)
问题是它不会每次都检测到右边缘滑动.有时它会多次检测到它.
无论是否检测到它在iPad上滑动右边缘时始终在控制台中显示以下信息:
2014-10-07 00:04:40.386 Office日志[1531:500896] _UIApplicationHandleEventFromQueueEvent中的意外nil窗口,_ windowowServerHitTestWindow :; layer =>
此消息的含义是什么?如何修复它以便始终检测到右边缘滑动?
我有一个具有panGesture功能的视图,但我需要以编程方式从一个点向另一个点发送一个pan-gesture.有没有办法在swift中使用具有特定时间间隔的动画?这是我尝试以编程方式调用pan手势:
var upPanPoint = CGPoint(x: contentView.center.x, y: contentView.center.y + 500)
var upPan = panGestureRecognizer.setTranslation(upPanPoint, inView: self)
onSwipe(upPan)
Run Code Online (Sandbox Code Playgroud)
这是识别平移手势的代码:
func onSwipe(panGestureRecognizer : UIPanGestureRecognizer!) {
let view = panGestureRecognizer.view!
print(view)
switch (panGestureRecognizer.state) {
case UIGestureRecognizerState.Began:
if (panGestureRecognizer.locationInView(view).y < view.center.y) {
self.viewState.rotationDirection = .RotationAwayFromCenter
} else {
self.viewState.rotationDirection = .RotationTowardsCenter
}
case UIGestureRecognizerState.Ended:
self.finalizePosition()
default:
let translation : CGPoint = panGestureRecognizer.translationInView(view)
view.center = self.viewState.originalCenter + translation
self.rotateForTranslation(translation, withRotationDirection: self.viewState.rotationDirection)
self.executeOnPanForTranslation(translation)
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我正在尝试实现UIScrollView,其中水平平移滚动浏览滚动视图中的图片,但垂直平移执行我的另一个操作.现在我有一个UIScrollView分页显示垂直滚动禁用,可以很好地滚动浏览图片,但我疯了,试图找到一种方法来拦截垂直平底锅,并调用我自己的方法而不是垂直平底锅只是被吃掉了滚动视图.我能够做到
UIPanGestureRecognizer *panUp = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
[self.scrollView addGestureRecognizer:panUp];
[scrollView.panGestureRecognizer setEnabled:NO];
Run Code Online (Sandbox Code Playgroud)
这使我可以完全控制我的handlePanGesture:方法中的平移,但这并不是特别有用,因为我觉得我基本上将重写所有我想避免的滚动逻辑.任何有关如何实现这一目标的帮助或指导将不胜感激.
谢谢!
我是iOS新手,我UIPanGestureRecognizer在我的项目中使用.在我有一个要求得到当前触摸点和之前的触摸点,当我拖着视图.我正在努力争取这两点.
如果我使用touchesBegan方法而不是使用UIPanGestureRecognizer,我可以通过以下代码得到这两点:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint touchPoint = [[touches anyObject] locationInView:self];
CGPoint previous=[[touches anyObject]previousLocationInView:self];
}
Run Code Online (Sandbox Code Playgroud)
我需要在UIPanGestureRecognizer事件火灾方法中得到这两点.我怎样才能做到这一点?请指导我.
UIScrollView我的视图控制器中有几个s.我想覆盖一个捕获2个手指滑动的视图,通过UIPanGestureRecognizer该视图不会记录UIScrollView滑动手势.
当我使用双指平移手势在我的内容上放置透明视图时,我的水龙头和1个手指滑动未被检测到.我尝试覆盖pointInside:方法返回NO
但是它没有记录我的2指滑动.
效果类似于4指滑动来更改应用程序.
objective-c ipad uigesturerecognizer ios uipangesturerecognizer
这是一个发生的视频:
基本上,如果我在平移时更改UIImageView(X)的图像属性,它会将视图中的所有控件恢复到原始的未打开位置.(它们都嵌入在UIView中,因此我可以"平移单元格",而UIImageViews在视图之外并且是独立的.)
如果我不更改图像:
为了记录,我改变图像,当用户平移一定量,我相信80点.
这是代码:
// Only allow the cell to be moved 100 pixels left or right
if (xPos <= 100 && xPos >= -100) {
// Move our cell to the xPos we defined
CGRect slidingViewFrame = self.slidingView.frame;
slidingViewFrame.origin = CGPointMake(xPos - 100, 0);
self.slidingView.frame = slidingViewFrame;
if (xPos >= 80) {
if (_removeIconIsActive == NO) {
// Change remove icon to a red, active state and animate the change
self.removeIconImageView.image = [UIImage imageNamed:@"remove-icon-active.png"];
_removeIconIsActive = …Run Code Online (Sandbox Code Playgroud) objective-c uiview uigesturerecognizer ios uipangesturerecognizer
我已经实现了UIPageviewContoller来支持屏幕半个底部的多个viewcontoller视图.现在我的问题是如何在我的网页浏览器控制器上支持这种子视图的Facebook样式平移效果.
我想实现他们已经在相机中应用的Facebook消息风格效果,用手指平移我们可以将视图作为全屏显示.当我们平移相同的视图时,它将在原始视角内进行调整.我已经附加了一些屏幕以便更好地理解.

它应该支持一体化的流行手势.

我能够得到类似的效果,但为此我已经添加了视图到主窗口,所以视图可以平移到全屏但是通过这种方法我无法实现交互式弹出iOS默认手势,这种方法对我当前的pageviewcontoller实现不好.
如果在窗口中添加视图比用户按下后退按钮而不是窗口元素将不会移动它将保留在窗口中,因此窗口方法不好.
有没有其他方法可以获得类似的效果?UIViewControllerInteractiveTransitioning可能有用吗?
提前致谢.我知道我会从你们那里得到更好的方法,这比将子视图添加到窗口更稳定.
我使用以下代码将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,但我不确定.如果这是正确的,我该如何解决这个问题.如果这不正确,请提供原因并解决.谢谢.
iOS 7提供了一个UIScreenEdgePanGestureRecognizer从屏幕边缘检测滑动的方法.可以使用Xcode中的iOS7模拟器模拟这个手势吗?单击并拖动屏幕区域外只会移动整个模拟器框架.
ios ×9
objective-c ×7
animation ×2
ipad ×2
xcode ×2
ios7 ×1
ios8 ×1
iphone ×1
swift ×1
touchesbegan ×1
uiscrollview ×1
uitableview ×1
uitouch ×1
uiview ×1