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
    A Look At Truecrypt The Open Source Security Tool
    Price Of Piracy
    Acer Aspire 5600U 23" Touchscreen All-in-One PC
    Zalman FX100-Cube Fanless Cooler
    Devolo dLAN LiveCam Starter Kit
    Has Apple Lost It? (Part 2)
    Has Apple Lost It? (Part 1)
    Sony Computer Entertainment (Part 3)
    Sony Computer Entertainment (Part 2)
    Sony Computer Entertainment (Part 1)
    Most View
    AMD A6-3500 - Llano integrated-graphics processors
    Samsung launched projector, smartphone, and 10.1'' note device
    Working with Access and Connectivity Policies in Vista
    Getting the Most Out of the Microsoft Outlook Client : Using Outlook 2007 (part 2) - Sharing Information with Users Outside the Company
    iPhone Application Development : Making Multivalue Choices with Pickers - Understanding Pickers
    Managing Windows Firewall in Windows Vista
    What To Look For When Buying A New Phone Or Tablet (Part 10)
    Delete & Recover Data (Part 4) - Securely Deleting Data Using Eraser 6.0
    The New Domain Names (Part 2)
    Windows Server 2008 : Domain Name System and IPv6 - DNS in Windows Server 2008 R2
    Customizing the Taskbar in Vista
    Kindle Fire HD - Most Advanced 7" Tablet (Part 2)
    Remote Administration of Exchange Server 2010 Servers : RDP with Exchange Server 2010 (part 1) - Planning and Using Remote Desktop for Administration
    Exchange Server 2010 server roles (part 1) - Mailbox Server role
    Nuforce Air DAC Review
    SQL Server 2005 Native XML Web Services : Exposing SQL Programmability as Web Services (part 1)
    SQL Server 2008 : Working with Multiple-Source Queries - Using Linked Servers
    Nintendo WII U - Modern HD Gaming Console (Part 5)
    SQL Server 2008 R2 : Creating and Managing Indexes - Creating Indexes (part 2) - Creating Indexes with SSMS
    Adobe InDesign CS5 : Importing Graphic Objects (part 3) - Using the Image Import Options Dialog Box