MOBILE

iPhone Application Development : Creating a Multi-View Toolbar Application (part 2) - Instantiating the View Controllers

2/28/2011 11:00:38 AM

Instantiating the View Controllers

Your project should now contain content for each of the views and all the view controller classes it needs to function. The classes, however, still need to be instantiated so that we have actual view controllers and view objects to use in the application.

Open MultipleViewsViewController.xib in Interface Builder. This file contains the parent view that we will be using to for the toolbar interface element, and it is also a logical place to add our other view controller instances.

Using the Library (Tools, Library), drag a view controller (UIViewController) into the Document window. We want this view controller to be an instance of our FirstViewController class. With the controller selected, press Command+4 to open the Identity Inspector. Use the drop-down menu to choose FirstViewController, as shown in Figure 5.

Figure 5. Update the view controllers to point to the classes you created earlier.


Next, the view controller must be updated to point to the correct XIB file (FileViewController.xib) for its view. Select the controller in the Document window and press Command+1 to open the Attributes Inspector. Within the NIB Name drop-down menu, choose FirstViewController, as shown in Figure 6.

Figure 6. Associate every view controller with the appropriate XIB file.


Repeat these steps for the SecondViewController and ThirdViewController classes. (That is, add a new view controller instance, set the class, and associate the view.) When finished, your MultipleViewsViewController.xib should look very similar to Figure 7.

Figure 7. Add three view controller instances to the XIB file.


With these changes, our project will build and instantiate the controllers, but there is still no way of displaying the different views. It’s time to add the toolbar controls and code to make that happen!

Other  
  •  Windows Phone 7 Development : Using Location Services - Simulating the Location Service
  •  Introducing the Windows Phone Location Service and Mapping APIs
  •  iPhone Application Development : Implementing a Custom Picker View (part 4) - Tweaking the Picker UI
  •  iPhone Application Development : Implementing a Custom Picker View (part 3) - Reacting to a Picker View Choice
  •  iPhone Application Development : Implementing a Custom Picker View (part 2)
  •  iPhone Application Development : Implementing a Custom Picker View (part 1)
  •  Windows Phone 7 Development : Isolated Storage - Working with Isolated Storage Settings
  •  Mobile Application Security : WebOS Security - Permissions and User Controls
  •  Mobile Application Security : WebOS Security - Code Security
  •  Windows Phone 7 Development : Working with Isolated Directory Storage (part 2)
  •  Windows Phone 7 Development : Working with Isolated Directory Storage (part 1)
  •  iPhone Application Development : Making Multivalue Choices with Pickers - Using Date Pickers (part 3)
  •  iPhone Application Development : Making Multivalue Choices with Pickers - Using Date Pickers (part 2) - Adding a Date Picker
  •  iPhone Application Development : Making Multivalue Choices with Pickers - Using Date Pickers (part 1)
  •  iPhone Application Development : Making Multivalue Choices with Pickers - Understanding Pickers
  •  Sync Your iPad with iTunes : Troubleshooting iTunes and the Sync
  •  Sync Your iPad with iTunes : Manually Transferring Music, Movies, Podcasts, and More on Your iPad (Drag-and-Drop Method)
  •  Windows Phone 7 Development : Internationalization - Using Resource Files to Localize Content
  •  Windows Phone 7 Development : Internationalization - Storing and Retrieving Current Culture Settings
  •  Mobile Application Security : WebOS Security - Development and Security Testing
  •  
    Top 10
    Value in focus : BenQ G1, Fujifilm XF1
    Nikon 1 V2 Digital Camera - Still Fast And Handles Better
    Time For The Android Camera : Nikon Coolpix S800c, Samsung Galaxy Camera
    AMD A10-5800K - Processor in a Box
    Giada Mini PC D2305 - A Change Of Shape
    Intel Solid State Drive 335 Series - Better Under The Hood
    Lenovo IdeaCentre A720 - The Ultimate Home PC
    Samsung Series 9 Ultrabook - An Expensive Ultrabook
    Apple iPad 4th Generation Wi-Fi (Late 2012)
    Samsung Galaxy Note 800 - A Fresh Challenge
    Most View
    Headset & Speaker Buyer’s Guide (Part 1)
    Algorithms for Compiler Design: REGULAR GRAMMAR
    How To Create A Lively Video Clip
    Speaker Docks Assemble (Part 1) - Sonic Gear Tatoo 303 2.1, Sonicgear DA-2001
    IPhone Cases Of The Year
    iStopMotion 3
    SQL Server 2008 : Performance Tuning - Using Dynamic Management Views
    Network Attached Storage Round-Up (Part 1) - The Benefits Of A NAS
    Windows 8 Special (Part 4)
    GoPro Hero3 Black Edition Review - Bring The Quality Of Action Cameras To A Next Level (Part 1)
    Predict The Weather (Part 1)
    Touchy Curve : BlackBerry Curve 9380
    The Tablet Wars (Part 3) - Barnes & Noble Nook HD
    Nvidia GeForce GTX 680 2GB - Nvidia’s Top-End single-GPU Card
    Security Report – June 2012 : Trojan Horses At The Gates Of OSX, Android Fortified, Picture Imperfect & LulzSec Beheaded
    Exchange Server 2010 : Installing OCS 2007 R2 (part 2) - Prepping the Domain & Delegating Setup and Administrative Privileges
    Programming Microsoft SQL Server 2005 : The XML Data Type (part 1) - Working with the XML Data Type as a Variable & Working with XML in Tables
    Using SharePoint Central Administration for Backup and Restore
    Windows Phone 7 Development : Working with Controls and Themes - Introducing the Metro Design System
    Datacolor SpyderLensCal (Part 1)