uitapgesturerecognizer

Animate a view on key window while dragging another view with UILongPressGestureRecognizer

核能气质少年 提交于 2019-12-13 19:18:15
问题 I have added UILongPressGestureRecognizer to a view, and after long press event, the user can drag the view. I have added a view on the key window (need the custom view over the navigation and tab bar controllers, that is why need to add it on key window) using below code: // add the custom view on the key window. UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow; [currentWindow addSubview:customView]; Now, when I am dragging the first view beyond the (screenSize/2) point,

iOS: Two Gestures, One Target-Action

本秂侑毒 提交于 2019-12-13 05:09:20
问题 I'm implementing the Messages app copy-message feature. You can either double tap or long press on a message to copy it. How do I do that? I was thinking of adding two gesture recognizers to the view, one UITapGestureRecognizer (with numberOfTapsRequired set to 2 ) and one UILongPressGestureRecognizer . They would both have the same target & action. Then, I think for each of them, I'd call requireGestureRecognizerToFail: , passing the other gesture recognizer. Is my thinking correct? Is there

Swift: addGestureRecognizer for UIView class

早过忘川 提交于 2019-12-13 04:58:37
问题 I use this code: class StarClass: UIView { @IBOutlet weak var bgStar: UIView! class func createMyClassView() -> StarClass { let myClassNib = UINib(nibName: "Star", bundle: nil) let nW = myClassNib.instantiate(withOwner: nil, options: nil)[0] as! StarClass nW.bgStar.layer.cornerRadius = 15 nW.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleStar(sender:)))) return nW } @objc func handleStar(sender: UITapGestureRecognizer) { print("iosLog STAR") } } After run,

add gesture recognizer uivew navigation bar swift not working

℡╲_俬逩灬. 提交于 2019-12-13 04:09:53
问题 I have a navigation controller with a navigation bar, I have added a UIView with subview of imageView and UILabel for titleView. I need to be able to click on that view to do something else with addGestureRecognizer on that view but nothing is printed on the console. The UIImageView has to be next to the UILabel Here is the code I tried so far private func setupNavBarWithUser() { let titleView = UIView() let width = titleView.sizeThatFits(CGSize(width: CGFloat.greatestFiniteMagnitude, height:

Triggering UITapGestureRecognizers from overlapping Views

喜你入骨 提交于 2019-12-13 03:22:49
问题 I have one main view and 4 subviews of the mainview they all have their UITapGestureRecognizer, when I tap on one subview how can it be triggered both views. Example below, if I tap to subview 1 desired log would be: subview1 is clicked MainView is clicked My Code override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let mainGesture = UITapGestureRecognizer(target: self, action: #selector(mainGestureActivated)) self.view

tap gesture on uiimage in collectionview

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 02:35:40
问题 In each cell of my UICollectionView , I have multiple object to interact with. So instead of use didSelect delegate method, I really wanted to add a tap gesture on each object of the cell. To make it simple, I removed all the other objects in the example: func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as!

Get tapped cell in UITapGestureRecognizer handler

微笑、不失礼 提交于 2019-12-12 15:58:26
问题 I have set up a gesture recognizer for my table cell in my IOS5 app: UITapGestureRecognizer* oneFingerDoubleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(cellOneFingerDoubleTap:)]; oneFingerDoubleTap.numberOfTapsRequired = 2; [cell addGestureRecognizer:oneFingerDoubleTap]; And implemented handler method: - (void)cellOneFingerDoubleTap:(id) sender { NSLog(@"taptap"); } It works fine. My problem is that I can not pass the cell was tapped or some other data with the

Detecting double and single tap on UITableViewCell to perform two action

一个人想着一个人 提交于 2019-12-12 09:39:24
问题 I have a PFQueryTableViewController in which I am trying to learn some tableView interactions. What I currently have: The tableView cell increases its height on a tap didSelectRowAtIndexPath or I can basically segue cell related data to next viewController using performSegueWithIdentifier together with prepareForSegue using a single tap. In the below code, if I comment the "Tap code to increases height of tableView cell" code, I can detect double tap. Other wise the single tap increases the

Handling Multiple GestureRecognizers

帅比萌擦擦* 提交于 2019-12-12 08:44:47
问题 I've run into an issue understanding UIGestureRecognizers . My goal right now is to have a set of GestureRecognizers to do different tasks, for example: override func viewDidLoad() { mainScene = GameScene(size: self.view.bounds.size) main = view as! SKView mainScene.panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(shiftView(recognizer:))) main.addGestureRecognizer(mainScene.panRecognizer) mainScene.tapRecognizer = UITapGestureRecognizer(target: self, action: #selector

cancelling a tap gesture recongiser

早过忘川 提交于 2019-12-12 04:05:12
问题 Referring to my last question: Sprite moves two places after being paused and then unpaused Hi, I have a tap gesture which moves a sprite in my game forward 1 space and when I press the pause button it continues to register the tap gesture and then when I resume the gameplay It moves two spaces. so I managed to define a bool variable that detects (using if statements) if I have paused the tap gesture var tapIsPaused: Bool = false func tapUp(){ if(tapIsPaused == true) { //do nothing } else if