Iphone Programming - understanding windows and views
When an Iphone application is running, it becomes the only main window displayed in the iphone. Normally when an application running its the only thing that the user is doing, so there is a single window open.
When a single windows is displayed in the iphone, the class that has to be called to display the window is the UIWindow class. Once this has been called then you will have your application window available to display the data you want.
A window on the iphone can only normally be changed and adjusted by the program you have built, and not directly by the user. So you will have to include calls to the close object, to close the window also.
On the Iphone the part of the SDK that takes care of the viewing functionality that shows your application is the model, view, and controller objects.
As well as creating a window for your iphone app, there are views that then can be layered on top of this window. An example would be a menu or a status bar. You have to note that there is a difference.
Each of the views that you add to the window of your iphone application become the child to the window, who is the parent object.
A view will usually give the type of functionality that requires input from your user, or is to display some piece of content to the user. The job of the view object is to create the content that is in the model object. This would be your graphics, or even a simple logo.
The view object will also respond to the touching of the screen, and will also provide any other controls for your user to interact with your application.
A window will have a number of sub views that are all part of the application, and the interaction with the user. The types of basic user interface items that you can expect to program with are text fields, toolbars and buttons.
When multiple views are added to the window, they actually form another hierarchy . The main view becomes a content view, and then each of the subsequent views from the objects become a sub view. Any views that are then added on top of the other views mean that the first view that was added is now refereed to as a super view.
A windows is provided to help give you a surface that you can actually display your content, and data on. This is what is called the root container, for the other views, since they are all part of this view in the hierarchy. Usually there should only be one window in each application.
A window provides a surface for drawing content and is the root container for
all other views.
There is typically only one window per application.
The Iphone SDK also has what are called controls. These are exactly what they sound like, they are the controls that include things like buttons or text fields. These controls are actually represented as sub views though. This is because they care managed by the view object. The Iphone user interface kit framework supplies the code that defines this view behavior.
This is all important to recognize, as its object orientated programming concepts that you are using.
To get started programming the iphone view, you will have to call the UIView class. This class defines the properties of a view object. There are then a number of sub classes of objects that work in the UIview class. These are UIButton and also UISlider. They will help you to control what happens when a user is interacting with this particular part of the iphone. These ready made classes help keep a consistency in your application that the users are already used too.
Container views are a way of going between the model and the view objects and actually doing specific actions with them. Without the container object view, there won't be much happening with your application. Take for example the class that actually adds the scrolling function that happens when you slide your finger accross the iphone screen. This function is called the UIScrollView class. If you then want to add for example a drop down menu that also is part of this functionality, you would call the UITableView. This view then inherits, through the heirachy the UIScrollViews capabilities, but also adds then the options for new tables and menus within you application.
Another example of a container class if the UIToolber class. This deals with the shortcuts, and buttons that would be displayed in your application to help the user navigate around.
A another required class is the UIControl Class. This is actually a subclass of the UIView class, and it includes anything that is touchable on your iphone screen. This can be the buttons, sliders or areas where you enter data. Controls are a subclass of the UIControl class. They are what will give you all the available options to help you create a program that can provide a level of functionality to your users interaction.
The classes of display views, are what give your application the iphone feel to it, and aesthetics that users come to appreciate that they will see on the iphone. An example of the display view controls include the UIMageView. This displays how your images that you have in your application are viewed on the screen.
Text and Web views
If you need to present and display text in your iphone application then you will need the UITextView class to make it readable. This class will help you display any amount of text that you have on the screen of the iphone.
The UIWebView class is what you need if you want to display the HTML text from the web, in the same way as an internet browser does. UIWebView also doubles as a way to help you display graphics and text in text display views that you call.
Alert views and action sheets
One of the more simplier to understand functions on the IPhone is the alert and action views. These will help give your user either a pop up, or a warning message, or even something that they need to respond to before they can continue.
The UIAlertView class will display the standard blue alert box to pop up onto the screen. The UIActionSheet class is a bit more subtle, and will display messages via a box that will slide in from the bottom of the screen. This is especially good for games, when as the user is collecting things, they are giving message to indicate that they have picked up some gold coins or a new weapon.
Its always worth having a go at similar applications to the ones that you are planning to build, since you will get a good feel for the types of controls, and functionality that you should think about, and how best you can present you application to the user.
If you want to provide your user with options to move around within the application, including a back and forward button, then you will be working with the tab bars and navigation bars. These help provide ways to stay in your application, and yet move around it in various ways.
View controllers provide the glue between the model-view design pattern of iphone development. They work by being the main communication tool between the Model classes and the View classes. Essentially doing the running around, collecting the data that you application needs and then passing it the view classes to display it correctly to the user. View controllers are what respond to any changes in the user interface, and what the user actually inputs. The view controller is called the target object when this happens.
All your data sources, and your table views will become useless unless you have the view controllers to manage the data flow between them. When you are dealing with most parts of the Iphone SDK interface, you will find that they each have their own corresponding controller view, to do the running around for them. This keeps the object itself, completely separate from the functions that come from this object.
More by this Author
The different types of printer interfaces and connection methods that are used with computers.
Different types of motherboards that are used in personal computers and laptops.
Good examples for ebay feedback.
No comments yet.