UIView vs UIViewController

后端 未结 3 873
[愿得一人]
[愿得一人] 2020-12-02 17:11

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.

3条回答
  •  再見小時候
    2020-12-02 17:43

    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.

    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.

提交回复
热议问题