Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning iOS 4 Application Development
This is the forum to discuss the Wrox book Beginning iOS 4 Application Development by Wei-Meng Lee; ISBN: 978-0-470-91802-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 26th, 2011, 07:15 PM
Authorized User
Points: 92, Level: 1
Points: 92, Level: 1 Points: 92, Level: 1 Points: 92, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Windows based versus View based

The Chapter 4 example of a Windows based application, pages 85-91, drags and drops a View Controller onto the window and then populates the view with various objects.

But it seems that one can display objects on a window without creating a View Controller, and there appear to be examples on the web of doing just that.

I've created a Windows based application, dragged and dropped a UIWebView onto it, along with two toolbar buttons, and with appropriate connections had no difficulty using them, no View Controller declared or used.

Can anyone explain exactly when a View Controller becomes necessary?

One of the things I need to do in my app is start with a full page of HTML, displayed using a UIWebView, then when certain hyperlinks are clicked, pop-up JPEG images and other effects. For the JPEG pop-ups, could that be done by the "Adding a View Controller and Views Programmatically" on pages 91-95?

Thanks.
  #2 (permalink)  
Old July 27th, 2011, 08:19 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

The UIViewController class has many delegate and template methods that are used regularly. If you place your interface directly on a window none of these methods are called. For example handling rotation. Your interface on the window, but not in a view - what happens if you change orientation?

Bob

Last edited by thepianoguy; July 27th, 2011 at 11:15 AM.. Reason: Incorrect statement about UIResponder and UIWindow
  #3 (permalink)  
Old July 27th, 2011, 10:08 AM
Authorized User
Points: 92, Level: 1
Points: 92, Level: 1 Points: 92, Level: 1 Points: 92, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know paraphrasing is dangerous, but essentially a UIWindow is a crippled UIViewController? Can do basic things but not more complex things?
  #4 (permalink)  
Old July 27th, 2011, 11:57 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

There was an error in my previous reply concerning UIWindow and UIResponder.
A UIWindow is basically the "real estate" for the various views to present themselves. You don't usually subclass a window. The customized behavior is contained in the ViewControllers. Since most programs have more than one view, and iOS typically has only one window, this makes sense. Each object, with its component parts, is self contained in its own class. There is additional functionality in a UIViewController than in a UIWindow because that is where the interface customization is supposed to be done.
I think of the UIWindow as a wall. On that wall I can place cabinets, paintings, pictures, a flat screen tv, projector screen, lights, speakers etc. and the wall is still just a wall. I can change, add and remove these objects as I wish. If I decide to make the wall a mural instead, I am stuck with that intruding on everything else. The window should be generic. If you customize the UIWindow with your interface objects directly you lose both the flexibility and the benefits of encapsulation, plus the additional functionality that is in the UIViewController.

A UIWindow is no more a crippled UIViewController, than a UIViewController is a crippled UITableViewController, or an NSObject is a crippled everything else.

Bob


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch. 4 -- Split-View Based App, pg. 121 sirab33 BOOK: Beginning iOS 4 Application Development 2 May 25th, 2011 06:37 PM
XSLT for converting column based xml to row based one sayusekhar XSLT 4 March 8th, 2011 08:20 AM
Chapter 4 - Split View-Based App johnoeffinger BOOK: Beginning iPad Application Development 4 May 21st, 2010 05:43 PM
Problems with view details based on querystring zacksofia ASP.NET 1.0 and 1.1 Basics 10 March 12th, 2006 07:45 PM
View records based on formula deepakbhota Crystal Reports 0 August 11th, 2005 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.