通过自定义手势连接到的视图来访问视图控制器是否合适?
我正在尝试用手势操纵 3D 对象。为了完成我的任务,我需要实现一些自定义手势识别器。
我正在子类化 UIGestureRecognizer 来检测手势。
我需要做的是访问屏幕上绘制的 3D 对象的顶点。我的 ViewController 类中有这些数据。比如说,我想知道侧面用户 r 接触的法线。
虽然,我可以尝试从视图访问 ViewController,该视图将通过某种方式连接到自定义手势,但我不认为这是访问对象的好方法。
我的问题是...
是否可以创建某个结构体的实例变量来保存 视图控制器中 3D 对象的顶点/法线信息。
如果不是,存储此类信息以渲染对象的最佳方法是什么。
我想在这里问的另一件事是
这是从自定义手势访问视图控制器的好方法吗? 它连接到的视图?
请建议我解决问题的最佳方法。
I am trying to manipulate a 3D object with gestures. In order to accomplish my task I need to implement some custom GesturesRecognizer.
I am subclassing UIGestureRecognizer to detect the gestures.
What I need to do is to access the vertices of the 3D object, which is drawn on the screen. I have this data in my ViewController class. Say, I want to know the normal of the facet use r is touching.
Although, I can try to access ViewController from the View which will be connected to the Custom Gesture by some means, I dont think, this is a good way to access the object.
My question here is...
Is it ok to make an instance variable of some struct holding
vertex/normal information of a 3D object in View controller.
If not what would be the best way to store such information to render objects.
Another thing I want to ask here is
Is it a good way to access View Controller from Custom Gesture through
the view it is connected to?
Kindly suggest me the best way handle my problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在视图控制器的代码而不是视图的代码中设置和处理手势识别器吗?这将使您能够以简单明了的方式访问视图控制器的数据。
关于顶点/法线结构,您是否考虑过为您的视图创建一个模型(数据源)并将此类数据保留在那里?从 MVC 的角度来看,这似乎是一个明智的解决方案。
Can't you set up and handle the gesture recognizer in view controller's code instead of view's code? That would enable you to access view controller's data in an easy and clear way.
And regarding vertex/normal struct, have you considered creating a model (data source) for your view and keeping that kind of data over there? That would seem a sane solution from MVC point of view.