uitapgesturerecognizer

Detect touch event on UIScrollView AND on UIView's components [which is placed inside UIScrollView]

假如想象 提交于 2019-11-27 12:27:59
问题 I have UIViewController on my simple storyboard IPad project which contains UIScrollView which is placed over entire surface (1024 x 768). I have created 3 XIB files which are UIViews which my application loads on start in viewDidLoad and add them into UIScrollView. Each of these 3 XIB files contains only one UIButton. This is hierarchy: ~ UIViewController ( UIViewControllerClass is class for this UIViewController) ~~ UIScrollView (contains 3 identical UIViews) ~~~ UIView ( UIViewClass is

iOS Detect tap down and touch up of a UIView

﹥>﹥吖頭↗ 提交于 2019-11-27 12:20:53
I am stuck with a problem of determining how to detect a UIView being touched down and UIView being tapped. When it is touched down, I want the UIView to change its background color. When it is touched, I would like the UIView to perform certain tasks. I would like to know how I am able to fix this problem. -(void)viewDidLoad { UITapGestureRecognizer *dismissGestureRecognition = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDismissDoubleTap:)]; dismissGestureRecognition.numberOfTapsRequired = 1; [sectionDismissDoubleView addGestureRecognizer

Passing through touches to UIViews underneath

心不动则不痛 提交于 2019-11-27 11:52:34
I have a UIView with 4 buttons on it and another UIView on top of the buttons view. The top most view contains a UIImageView with a UITapGestureRecognizer on it. The behavoir I am trying to create is that when the user taps the UIImageView it toggles between being small in the bottom right hand corner of the screen and animating to become larger. When it is large I want the buttons on the bottom view to be disabled and when it is small and in the bottom right hand corner I want the touches to be passed through to the buttons and for them to work as normal. I am almost there but I cannot get

UITapGestureRecognizer tap on self.view but ignore subviews

走远了吗. 提交于 2019-11-27 10:59:36
I need to implement a feature that will invoke some code when I double tap on the self.view (view of UIViewCotroller ). But the problem that I have other UI object on this view and I don't want to attach any recognizer object to all of them. I found this method below how to make gesture on my view and I know how it works. Right now I am in front of handicap which way to choose for create this recognizer ignoring subview. Any ideas? Thanks. UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; [doubleTap

Click Event on UIImageView programmatically in ios

南楼画角 提交于 2019-11-27 09:23:22
问题 I am displaying a image from code here is the code UIImageView *preArrowImage =[[UIImageView alloc]init ]; preArrowImage.image =[UIImage imageNamed:@"arrowprev.png"]; preArrowImage.frame = CGRectMake(20, 60, 10, 30); [self.view addSubview:preArrowImage]; I want to handle the touch event on the preArrowImage programmatically. 回答1: Objective-c UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected)]; singleTap.numberOfTapsRequired =

Tap detection not working on UIImageView

荒凉一梦 提交于 2019-11-27 08:59:12
问题 In my .m file I added: @property (strong, nonatomic) UIImageView *star1; Then in a method I did: UIImage *star1Image; star1Image = [UIImage imageNamed:@"staryes"]; self.star1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)]; self.star1.tag = 800; [self.star1 setImage:star1Image]; [ratingLabelBody addSubview:self.star1]; After a few lines not related to this I have: [self.star1 setUserInteractionEnabled:YES]; UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc]

Pass a NSDictionary as parameter to UITapGestureRecognizer

对着背影说爱祢 提交于 2019-11-27 07:13:35
问题 I want to pass a NSArray as a parameter to UITapGestureRecognizer and access it in downloadOptionPressed method. How can I do this ? The NSArray NSArray *parameters = [NSArray arrayWithObjects:currentTrack, nil]; Creating the UITapGestureRecognizer UITapGestureRecognizer *downloadOptionPressed = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(timeFrameLabelTapped:)]; [downloadOption addGestureRecognizer:downloadOptionPressed]; The downloadOptionPressed method -(void

How to capture Tap gesture on MKMapView

孤街浪徒 提交于 2019-11-27 06:45:01
I am trying to capture tap event on my MKMapView , this way I can drop a MKPinAnnotation on the point where user tapped. Basically I have a map overlayed with MKOverlayViews (an overlay showing a building) and I would like to give user more information about that Overlay when they tap on it by dropping a MKPinAnnotaion and showing more information in the callout. Thank you. You can use a UIGestureRecognizer to detect touches on the map view. Instead of a single tap, however, I would suggest looking for a double tap ( UITapGestureRecognizer ) or a long press ( UILongPressGestureRecognizer ). A

Unrecognized selector sent to instance Swift 3

本小妞迷上赌 提交于 2019-11-27 06:26:56
问题 I want to implement TapGestureRecognizer with the selector , below is the code where I added tapGestureRecognizer to my imageView let tapFirstGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(assignImage(_:))) firstImageView.isUserInteractionEnabled = true firstImageView.tag = 1 firstImageView.addGestureRecognizer(tapFirstGestureRecognizer) Here is the action method func assignImage(_ sender: UIImageView){ imagePicker.allowsEditing = false imagePicker.sourceType =

iOS How to dismiss UIAlertView with one tap anywhere?

瘦欲@ 提交于 2019-11-27 04:39:10
问题 I want to dismiss UIAlertView anywhere outside it with one tap. I want to show a UIAlertView without any button. I have standard UIAlertView codes here, but I need input how to dismiss it, if it is possible. With UITouch? With UITapGestureRecognizer? Thank you. EDIT: in viewDidLoad alertview initialization here with name "alert" if (alert) { emptyview = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,480)]; emptyview.backgroundColor = [UIColor clearColor]; [self.view addSubview:emptyview];