Tag: uitapgesturerecognizer

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, […]

双击UICollectionViewCell上的手势?

我想双击UICollectionViewCell来像OkCupid App那样喜欢这个configuration文件。 我已经在集合视图上应用了Tap Gesture,但它不起作用。 当我尝试每次didSelectCollectionViewCell方法调用时双击单元格。

当superview有手势时,collectionView没有调用didSelectItemAtIndexPath

当superview有tapGesture.is时,collectionView没有调用didSelectItemAtIndexPath为什么? 为什么根据响应者链打印“doGesture”? initCollectionView然后添加到self.view 在self.view中使用addTapGesture 点击iPhone中的项目。 不要调用didSelectItemAtIndexPath。 – (void)viewDidLoad { [super viewDidLoad]; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; self.collectionView = [[MyCollectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height – 100) collectionViewLayout:flowLayout]; [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"abc"]; self.collectionView.delegate = self; self.collectionView.dataSource = self; [self.view addSubview:self.collectionView]; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doGesture)]; tapGesture.delegate = self; [self.view addGestureRecognizer:tapGesture]; } […]

UITextField TapGesture不响应iOS 7.1

我有一个uitextfield编程添加到查看。 我需要显示一个UIPickerview,当我点击它,我已经添加了一个UITapgestureRecognizer的用户和交互也启用。 哪个工作正常,直到IOS 7.0。 但是,当我更新到IOS 7.1,而不是被调用。

如何检测哪个图像已经被快速切入

我在ViewController上创build了6个UIImageView,后来我将其添加到了所有的TapGestureRecognizers中。 我想这样做,根据被点击的图像,另一个ViewController将打开并显示某些信息。 要做到这一点,我需要知道哪个图像被点击。 我将如何在Swift中执行此操作?

触动延迟

我有一个UIView的子类,并添加了touchesBegan和touchesEnd方法… 在touchesBegan ,我使用self.backgroundColor = [UIColor greenColor] …在touchesEnd中将backgroundColor从白色设置为绿色。将颜色重置为白色。 它的工作,但非常缓慢。 通过点击视图,需要0.5 – 1.0秒,直到看到绿色。 在UITableViewselect一个单元格要快得多。

将parameter passing给Swift中的Selector

我正在构build一个跟踪大学课程阅读作业的应用程序。 每个ReadingAssignment都包含一个Bool值,用于指示阅读者是否完成阅读任务。 ReadingAssignments被收集到WeeklyAssignment数组中。 我希望让用户能够触摸标签,并出现复选标记,并将分配显示为已完成。 我想这个接触也更新.checked属性为true,所以我可以坚持数据。 所以,我试图让gestureRecognizer调用labelTicked()方法。 这工作和打印到控制台。 但是,当我尝试传递赋值参数时,它会编译,但碰到“无法识别的select器”错误。 我已经阅读了我可以在这里find的每一个主题,并且没有find解决scheme。 他们都说“:”表示带有参数的select器,但还是没有。 你能看到我做错了吗? func configureCheckmark(cell: UITableViewCell, withWeeklyAssignment assignment: WeeklyAssignment) { let checkLabel = cell.viewWithTag(1002) as! UILabel checkLabel.userInteractionEnabled = true let gestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("labelTicked:assignment")) checkLabel.addGestureRecognizer(gestureRecognizer) } @objc func labelTicked(assignment: WeeklyAssignment) { assignment.toggleCheckmark() if assignment.checked { label.text = "✔︎" } else { label.text = "" } […]

当标签被点击时返回标签

我在我的视图中有5个标签,分别标记为1,2,3,4和5.我已经启用了用户交互 ,并添加了一个轻击手势。 现在我想要的是标签被触摸的标签。 我正在做这样的事情: tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGestureSelector)]; tapGesture.numberOfTapsRequired = 1.0; – (void)tapGestureSelector :(id)sender { // I need the tag to perform different tasks. // So that I would like to get the touched label's tag here. } 如果我不清楚我的问题,请问我。 感谢您期待的帮助。

点击多个imageview内的scrollview不滚动事件,只有第一个imageview轻拍手势工作?

情景是我有我已经添加一个滚动视图,然后tapgesture每个imageview添加,但只有第一个imageview射击事件添加imageview。 试过了: 1.创build了imageview的扩展 extension UIImageView { public func openMenu() { let tapGestureRecognizer = UITapGestureRecognizer(target:self, action:Selector("handleTapGesture:")) //mImg.addGestureRecognizer() self.addGestureRecognizer(tapGestureRecognizer) print("open") } } 2.在循环中添加轻击手势(添加滚动视图的方式与添加的方式相同) //the loop go till all images will load for var index = 0; index < imagesName.count; index++ { let mImg: UIImageView = UIImageView() let pDict = homePageProductArr[index] as NSDictionary //Create a UIVIEW let containerView:UIView […]

tableView在执行didSelectRowAtIndexPath之前由于一个gestureRecognizer而隐藏

我正在尝试处理tableViewCell被挖掘,但问题是,这是一个“临时tableView”。 我已经编码,以便它会出现在用户正在编辑UITextField时,但是,然后我设置了一个手势识别器,以便在用户单击远离UITextField的某个地方单击时将tableview设置为隐藏。 我的手势识别器设置如下: UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)]; [tap setCancelsTouchesInView:NO]; [self.view addGestureRecognizer:tap]; 但是,在调用didSelectRowAtIndexPath之前调用dismissKeyboard,所以我想处理事件的TableView变为隐藏,因此永远不会调用此函数。 我的问题是:有没有人有如何解决这个问题,所以didSelectRowAtIndexPath将在tableView隐藏之前执行? 我有一个想法,以某种方式看看如果tableView是来自哪里,如果是的话,那么不要执行dismissKeyboard中的“隐藏tableview”行。 这可能吗? 对不起,但我是新的iOS开发,所以感谢您的任何意见!