UIView和UIViewController [英] UIView vs UIViewController

查看:103
本文介绍了UIView和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!

推荐答案

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.

这是

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和UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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