uitapgesturerecognizer

iOS7: UITapGestureRecognizer reuse issue

狂风中的少年 提交于 2021-02-09 11:43:12
问题 I set three buttons. Every button is tagged 1...3. My UITapGestureRecognizer works only once and only for first UIButton. Can't select other two options. Code: - (void)viewDidLoad { [super viewDidLoad]; UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonTapped:)]; recognizer.delegate = self; recognizer.cancelsTouchesInView = NO; [recognizer setNumberOfTapsRequired:1]; [_btnNegative addGestureRecognizer:recognizer]; [_btnNeutral

iOS7: UITapGestureRecognizer reuse issue

。_饼干妹妹 提交于 2021-02-09 11:42:09
问题 I set three buttons. Every button is tagged 1...3. My UITapGestureRecognizer works only once and only for first UIButton. Can't select other two options. Code: - (void)viewDidLoad { [super viewDidLoad]; UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonTapped:)]; recognizer.delegate = self; recognizer.cancelsTouchesInView = NO; [recognizer setNumberOfTapsRequired:1]; [_btnNegative addGestureRecognizer:recognizer]; [_btnNeutral

Tap Gesture Recognizer not received in custom UIView embedded in super view

回眸只為那壹抹淺笑 提交于 2021-02-08 11:26:59
问题 I am trying to create a custom UIView/Scrollview named MyScrollView that contains a few labels (UILabel), and these labels receive tap gestures/events in order to respond to user's selections . In order to make the tap event work on the UILabels, I make sure they all have userIteractionEnabled = true and I created a delegate as below: protocol MyScrollViewDelegate { func labelClicked(recognizer: UITapGestureRecognizer) } The custom UIView is being used in ScrollViewController that I created,

How to get exactly the same point on different screen sizes?

五迷三道 提交于 2021-02-05 07:48:58
问题 I want to call the action (go to another view) when user tap specific area of image (black dots): . Image fills whole view, content mode is 'Aspect Fit'. The problem is that when I setup it on one screen size (e.g. iPhone 8) on another the 'tap area' is shifted. I've tried to solve this with button and constraints or UITapGestureRecognizer with point conversion using screen resolution (nativeBounds), but nothing helps. 回答1: It is possible to use constraints to match the positions of the

Tapping an MKMapView in SwiftUI

耗尽温柔 提交于 2021-01-29 19:43:14
问题 I have a map in a SwiftUI app. It is working up to a point; but now I want to be able to tap on it and know the latitude and longitude of the tap. Here is the current code: import SwiftUI import MapKit struct MapView: UIViewRepresentable { @Binding var centerCoordinate: CLLocationCoordinate2D func makeUIView(context: Context) -> MKMapView { let mapView = MKMapView() mapView.delegate = context.coordinator let gRecognizer = UITapGestureRecognizer(target: context.coordinator, action: #selector

Create a clickable map preview using MKMapSnapshotter

我与影子孤独终老i 提交于 2021-01-29 04:56:06
问题 I have a map that currently shows the user's current location with no pin to show them exactly where they are. I want to make the map a photo of where the user's set location is. I only know how to show where their device is and need them to be able to set their base of operations. I don't need specific addresses. I just need the city where they reside. I then need the image to be able to be tapped on. When tapped, the image makes the MapKit full screen and interactive. They can then zoom

Create a clickable map preview using MKMapSnapshotter

二次信任 提交于 2021-01-29 04:52:02
问题 I have a map that currently shows the user's current location with no pin to show them exactly where they are. I want to make the map a photo of where the user's set location is. I only know how to show where their device is and need them to be able to set their base of operations. I don't need specific addresses. I just need the city where they reside. I then need the image to be able to be tapped on. When tapped, the image makes the MapKit full screen and interactive. They can then zoom

Swift - How to add tap gesture to array of UIViews?

旧城冷巷雨未停 提交于 2021-01-29 01:37:41
问题 Looking to add a tap gesture to an array of UIView s - without success. Tap seems not to be recognised at this stage. In the code (extract) below: Have a series of PlayingCardViews (each a UIView ) showing on the main view. Brought together as an array: cardView . Need to be able to tap each PlayingCardView independently (and then to be able to identify which one was tapped). @IBOutlet private var cardView: [PlayingCardView]! override func viewDidLoad() { super.viewDidLoad() let tap =

UITapGestureRecognizer not attaching action

吃可爱长大的小学妹 提交于 2021-01-28 06:15:02
问题 I created a separate class for View. I left all the functions in the Controller. But when I add a click on the picture, it doesn't work for some reason. import UIKit class APOTDView: UIView { var imageView: UIImageView = { let imageView = UIImageView() imageView.translatesAutoresizingMaskIntoConstraints = false imageView.isUserInteractionEnabled = true let tap = UITapGestureRecognizer(target: self, action: #selector(APOTDViewController.imageTapped(_:))) imageView.addGestureRecognizer(tap)

iOS - Tap Gesture issue on image view

心已入冬 提交于 2021-01-28 01:54:23
问题 I am slowly working my way through Apple's learn developing for Swift and I keep running into an issue with my tap gesture. I have re-created the project numbers times all with the same outcome. I add a tap gesture to an image view and this should open the photo library from my computer. Nothing happens. When I download and run the sample file from Apple everything works. When I copy and paste the code from Apple's to mine, again, nothing happens. I have gone through everything that I can but