UIView vs UIViewController [英] UIView vs UIViewController

查看:19
本文介绍了UIView vs UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我对 iphone 开发真的很陌生,而且我的知识已经很长了.我只需要帮助决定如何将这 4-6 张图片编程到我的项目中.

Ok so i am realllly new to the iphone development and i've gotten pretty far for my knowledge. I just need help deciding how to program these 4-6 pictures into my project.

我基本上想制作一本漫画书,让用户能够从一张图片滑动到另一张图片.所有这些图片应该在 UIVIEW 还是 UIViewController 中?

I basically want to make a comic book with the user being able to swipe from one picture to another. Should all these picture be in UIVIEW or UIViewController?

以及连接这些图片以便我可以添加触摸代码的任何提示都很棒!

and any tips on connecting these pictures so that i can then add the code for touch would be awesome!

推荐答案

A UIViewController 不能显示任何东西;它只是协调 UIView 的显示.所以实际的图片需要在 UIView 中完成.此外,您的 UIView 负责识别触摸、手势等.不过,这就是它结束的地方;程序的实际反应应该取决于 UIViewController.

A UIViewController cannot display anything; it simply coordinates the display of a UIView. So the actual pictures are going to need to be done in a UIView. In addition, your UIView is responsible for recognizing touches, gestures, etc. That's where it ends, though; the actual reaction of your program should be up to the UIViewController.

换句话说,您将教 UIView 子类如何识别向左或向右滑动,一旦确定发生了滑动,它就会通知您的 UIViewController 子类该事件.然后控制器会决定接下来显示什么图片,并告诉视图进行设置.

In other words, you'd teach a UIView subclass how to recognize a swipe to the left or right, and once it had decided that a swipe had taken place, it would notify your UIViewController subclass of that event. The controller would then decide what picture would be displayed next, and tell the view to set it up.

这是模型视图的一部分-控制器 模式.这是 iPhone 开发中众所周知且广泛使用的模式,因此您最好仔细阅读它.

This is part of the Model-View-Controller pattern. It's a well-known and widely-used pattern in iPhone development, so you'd be well served to read up on it.

这篇关于UIView vs UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆