Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView vs UIViewController

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.

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!

like image 992
Dane Avatar asked Jul 20 '09 01:07

Dane


People also ask

What is the difference between UIView and UIViewController?

They are separate classes: UIView is a class that represents the screen of the device of everything that is visible to the viewer, while UIViewController is a class that controls an instance of UIView, and handles all of the logic and code behind that view.

Is UIViewController a subclass of UIView?

Instead, you subclass UIViewController and add the methods and properties needed to manage the view controller's view hierarchy. A view controller's main responsibilities include the following: Updating the contents of the views, usually in response to changes to the underlying data.

What is UIViewController Swift?

A UIViewController is an object which manages the view hierarchy of the UIKit application. The UIViewController defines the shared behavior and properties for all types of ViewController that are used in the iOS application. The UIViewController class inherits the UIResponder class. ADVERTISEMENT. ADVERTISEMENT.

How do I present UIView in Swift?

Open Xcode ▸ File ▸ New ▸ File ▸ Cocoa Touch class ▸ Add your class name ▸ Select UIView or subclass of UIView under Subclass of ▸ Select language ▸ Next ▸ Select target ▸ Create the source file under your project directory. Programatically create subviews, layout and design your custom view as per requirement.


1 Answers

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.

like image 165
BJ Homer Avatar answered Oct 01 '22 20:10

BJ Homer