简体   繁体   English

iOS:从另一个视图以编程方式调用 onTapGesture

[英]iOS : Programmatically call onTapGesture from another view

I currently have a UIView, call it (A), that is outsourced out into a 3rd party library.我目前有一个 UIView,称之为 (A),它外包给了 3rd 方库。 Pressing onTapGesture physically would be simple, but the problem here is that this (A) is on another view hierarchy, versus the one I have.在物理上按下 onTapGesture 会很简单,但这里的问题是这个 (A) 位于另一个视图层次结构上,而不是我拥有的层次结构上。 The reason for this is that I apply transforms to this separate from (A).这样做的原因是我将变换应用于与(A)分开的这个。

Im deciding on delegating a UIButton that will programmatically call the UIView in question's onTapGesture, is there a way to do this?我决定委托一个 UIButton 以编程方式调用有问题的 UIView 的 onTapGesture,有没有办法做到这一点?

I do not have access to this 3rd party library's selector for onTap.我无权访问此 3rd 方库的 onTap 选择器。

This is a very late answer to your question.这是对你的问题的一个很晚的答案。 If you still working on this may be my answer will be helpful or may be someone else will find it helpful.如果您仍在努力,我的回答可能会有所帮助,或者其他人会发现它有帮助。

The gesture doesn't expose its target and action.手势不会暴露其目标和动作。 In this case may be creating a fake touch programatically will be helpful.在这种情况下,以编程方式创建假触摸可能会有所帮助。 As you have UIView you can easily get the window of that view.由于您拥有UIView您可以轻松获得该视图的window With window find out the x,y co-ordinate and create a fake UITouch event.使用 window 找出 x,y 坐标并创建一个假的UITouch事件。 I also had similar kind of problem and creating fake touch worked for me.我也有类似的问题,创造假触摸对我有用。 This is the link I referred for creating fake touches. 是我参考的用于创建假触摸的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS从另一个视图跳过方法调用 - iOS Skipping a Method Call From Another View 如何通过 SwiftUI 中列表的每个元素的 onTapGesture 切换到另一个视图? - How to switch to another view by each element's onTapGesture of a list in SwiftUI? 从另一个View Controller iOS StoryBoard调用方法 - Call Method From Another View Controller iOS StoryBoard iOS:如何从另一个视图控制器调用根控制器 - iOS: How to call root controller from another view controller iOS如何从另一个View Controller Swift调用func - iOS How to call func from another View Controller Swift ios自动布局另一个视图(分层)的边缘上的叠加视图 - ios autolayout overlay view on edge of another view (layering), programmatically How to call UIButton action from view controller to another view controller in iOS Swift? - How to call UIButton action from view controller to another view controller in iOS Swift? 从另一个视图调用对象 - Call object from another View 从另一个视图调用UITableViewFunction - Call a UITableViewFunction from another view iOS9:将以编程方式添加的视图居中于另一个以编程方式添加的视图内 - iOS9: Centering programmatically added view inside another programmatically added view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM