Tag: uigesturerecognizer

UITapGestureRecognizer仅触发UIScrollView的开始区域

我有几个子视图添加到主视图控制器中的UIScrollView。 每个子视图的视图控制器都有自己的图标识别器。 问题是,只有在屏幕上的起始区域轻敲是公认的。 在滚动视图并敲击起始区域之后,敲击处理程序将不再被调用。 这个postUIButton在UIScrollView的不可见区域似乎是相关的,但其解决scheme的描述是不是真的很清楚我… 一个简单的报告项目可以在dropbox链接find 谢谢。

取消UILongPressGesture

我无法取消UILongPressGesture。 手势连接到一个button,当按下button时,录音机开始录制audio。 当我离开button时,我想让录音停止。 任何帮助表示赞赏,谢谢! @IBAction func recordAudio(sender: AnyObject) { if sender.state == UIGestureRecognizerState.Ended { session.setCategory(AVAudioSessionCategoryPlayback, error: nil) recorder.stop() recordButton.backgroundColor = UIColor.whiteColor() save() } else if sender.state == UIGestureRecognizerState.Began { session.setCategory(AVAudioSessionCategoryRecord, error: nil) recorder.record() recordButton.backgroundColor = UIColor.greenColor() } else if sender.state == UIGestureRecognizerState.Cancelled { recorder.stop() recordButton.backgroundColor = UIColor.redColor() } } 编辑 – 拿2 @IBAction func recordAudio(sender: […]

在UIImageView的不同区域识别UIGesture

我有这个形象: 我想要做的是添加一个UITapGestureRecognizer这个图像(或者我可以拆分图像的不同部分组成,并为每个部分添加一个UITapGestureRecognizer),以便有不同的行动根据叶轻拍。 如果我将图像分成不同的图像,每个图像的UIImageViews可能会重叠,轻敲一个将被认为是另一个轻拍。 只有一个图像意味着要知道属于一个叶子的屏幕点,而不是另一个。 任何线索如何做到这一点将非常感激。 谢谢

在UIScrollview上水平显示图像的ipad和获取图像的标记点击

我在UIScrollView中显示图像与UIImageView.I添加UIGestureRecognizer到每个ImageView,我也设置图像视图的标签属性。我想标记的图像视图上点击特定的图像视图。但我只是得到最后ImageView.Pasting代码below.Your帮助将不胜感激。 UITapGestureRecognizer *tapRecognizer; tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewDidTapped:)]; tapRecognizer.numberOfTapsRequired = 1; tapRecognizer.delegate = self; scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(5, 60, self.view.bounds.size.width-20, self.view.bounds.size.height-100)]; scrollView.delegate = self; scrollView.pagingEnabled = YES; scrollView.scrollEnabled = YES; scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; [scrollView setCanCancelContentTouches:YES]; [scrollView setUserInteractionEnabled:YES]; float width; for (NSDictionary *dict in object) { UIImageView *backgroundImageView = [[UIImageView alloc]initWithFrame:CGRectMake(width, 0, self.view.bounds.size.width-20, self.view.bounds.size.height-40)]; NSDateFormatter […]

如何向右滑动以在Swift 3中显示新的View Controller?

我想能够在我的ViewController ,将显示另一个视图控制器, CommunitiesViewController 。 我已经看了其他线程,发现了一些这样做,虽然我相信他们是斯威夫特2。 这是我在我的ViewController使用的代码: override func viewDidLoad() { super.viewDidLoad() let swipeRight = UISwipeGestureRecognizer(target: self, action: Selector(("respondToSwipeGesture"))) swipeRight.direction = UISwipeGestureRecognizerDirection.right self.view.addGestureRecognizer(swipeRight) } func respondToSwipeGesture(gesture: UIGestureRecognizer) { print ("Swiped right") if let swipeGesture = gesture as? UISwipeGestureRecognizer { switch swipeGesture.direction { case UISwipeGestureRecognizerDirection.right: //change view controllers let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let […]

旋转变换后更改uiview大小

我的代码需要来自专业xcoders的一些帮助:-) 我有一个名为“headline”的可拖动的uitextview,它是“mainstage”中的一个子视图。 我还添加了一个捏手势来更改uitextview中的字体大小。 一切工作正常,但最后的基本function,我真的需要的是uitextview的旋转。 所以我添加了一个uislider旋转和volia! 它也有效。 但是在这个转换之后,当它通过捏手势变成一个新的大小时,uitextview会变得疯狂。 (* uitextview的位置和大小) 在文档的一些研究后,我发现“一些有用的警告”(框架): 如果要在框架矩形更改时调用drawRect:方法,请将contentMode属性设置为UIViewContentModeRedraw 很不错…但是我不知道要把它放在我的代码里 换句话说:如何改变旋转后的uiview的帧大小? (myview.transform) 感谢大家帮助这个… 这是我的代码: – (void)viewDidLoad { // CREATE MAINSTAGE mainstage = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)]; mainstage.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height); mainstage.showsVerticalScrollIndicator=NO; mainstage.scrollEnabled=NO; mainstage.userInteractionEnabled=YES; mainstage.backgroundColor = [UIColor colorWithRed: 1.0 green: 1.0 blue: 1.0 alpha: 1.0]; mainstage.layer.masksToBounds = YES; [self.view addSubview:mainstage]; // CREATE […]

如何正确地得到一个手势识别器来根据速度stream畅地旋转一个精灵

我有一个Sprite通过纹理数组进行animation处理, spinLeft增加了数组索引,而spinRight减less了索引,如下面对我的其他问题的回答所示: https://stackoverflow.com/a/44792902/6593818 animation工作正常,但现在我试图通过手势识别器或其他forms的input来控制animation 。 在引用的问题中,旋转函数有一个速度input(TimeInterval),所以我只需要一个手势识别器的输出: 我想弄清楚如何让对象对我的手指做出反应,就像本video所示: https : //youtu.be/qjzeewpVN9o video不仅仅是一个基本的UIPanGesture阅读速度,我想。 至less,我不知道如何实现它。 这个项目是通过摄影展示朋友的雕塑。 func spin(direction: Direction, timePerFrame: TimeInterval) { nextTextures = [] for _ in 0…6 { var index = initialTextures.index(of: sprite.texture!) // Left is ascending, right is descending: switch direction { case .left: if index == (initialTextures.count – 1) { index = 0 } […]

Ios Swift Override UItextField的双击

我想在UITextField上双击编写一个自定义代码,并阻止默认文本编辑和popup键盘。 我已经尝试了以下,迄今没有任何工作。 请帮我解决这个问题。 let gestureArray = NamTxtBoxVal.gestureRecognizers var tapGesture = UITapGestureRecognizer() for idxVar in gestureArray! { if let tapVar = idxVar as? UITapGestureRecognizer { if tapVar.numberOfTapsRequired == 2 { tapGesture = tapVar NamTxtBoxVal.removeGestureRecognizer(tapGesture) } } } let doubleTap = UITapGestureRecognizer(target: self, action: #selector(namFnc(_:))) doubleTap.numberOfTapsRequired = 2 doubleTap.delegate = self tapGesture.requireGestureRecognizerToFail(doubleTap) NamTxtBoxVal.addGestureRecognizer(doubleTap) 我也试过: func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, […]

为什么在这个IOS代码中仍然会出现双击?

背景 – 我有一个标注(自定义视图添加到注释视图)的地图(MapKit) – 我已经设法确保在标注视图上做出的“长按”手势没有被拾取(见下面,使用“ shouldReceiveTouch“) 问题我不能做的是同样的事情(即忽略)在标注视图上双击,因为MapKit地图仍然以某种方式挑选并放大。我试着把双击手势放到陷阱它,但它似乎并没有工作。 Mapkit视图委托代码 手势识别器的设置 // Gesture Recogniser (Long Press) let longPressGR = UILongPressGestureRecognizer(target: self, action: "longPressAction:") longPressGR.minimumPressDuration = 1 longPressGR.delegate = self self.mapView.addGestureRecognizer(longPressGR) // Gesture Recogniser (Double Tap) let doubleTapGR = UITapGestureRecognizer(target: self, action: "doubleTapAction:") doubleTapGR.numberOfTapsRequired = 2 doubleTapGR.delegate = self self.mapView.addGestureRecognizer(doubleTapGR) 为UIGestureRecognizerDelegate实现“shouldReceiveTouch” extension GCMapViewHelper : UIGestureRecognizerDelegate { func gestureRecognizer(gestureRecognizer: […]

无法使用UILongTouchGestureRecognizer从MKMapView获取坐标

我正在使用iOS 6,而且我已经阅读了很多方法来完成这个任务(包括很多从堆栈溢出),但没有成功。 这是我试过的,分成“阶段”: 创build一个UILongTouchGestureRecognizer来接收MKMapView长触摸。 我尝试通过我的故事板添加一个UILongTouchGestureRecognizer ,并通过Connections Inspector连接sockets,委托等。 我已经尝试以编程方式创buildUILongTouchGestureRecognizer ,使用mapView作为目标进行初始化,将self作为目标,将UILongTouchGestureRecognizer作为目标进行初始化。 使用UILongTouchGestureRecognizer的select器方法接收触摸手势,获取CGPoint并将其转换为CLLocationCoordinate2D对象。 我试过了: 使用[mapView convertPoint:(CGPoint)toCoordinateFromView:self.mapView]; 使用MKMapPoint aPoint = MKMapPointMake(aCGPoint.x, aCGPoint.y); 首先,然后使用MKCoordinateForMapPoint(aMapPoint)来获取CLLocationCoordinate2D 。 直接访问UILongPressGestureRecognizer并使用方法调用中的(UILongPressGestureRecognizer *)sender来获取CGRect的x,y。 结果 简而言之,这就是我使用NSLog检查值时所得到的结果,不pipe使用什么方法。 – 对于UILongPressGestureRecognizer给出的X,Y,x似乎在200和420的范围内波动UILongPressGestureRecognizer的范围在UILongPressGestureRecognizer – 700之间。 – 经过长时间触摸并印在日志上的纬度和经度,奇怪的是,只有在小数点85.051XX(纬度)和-179.9997XX(经度)之后的第三个 – 第六个十进制值之间变化。 这里是我尝试过的一些代码的例子 – (void)viewDidLoad { NSLog(@"View did load"); [super viewDidLoad]; UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:mapView action:@selector(handleLongPress:)]; mapView = [[MKMapView alloc] init]; } – […]