ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Iphone Programming - understanding windows and views

Updated on August 7, 2011

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.

view

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.

The window

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.

Controls

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.

UIView class

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

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.


Controls

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.

Display views

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.

Navigation views

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

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.

working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)