【iphone开发书籍大全】 beginning iphone sdk programming with objectivec 部分3.pdf
【iphone开发书籍大全】 beginning iphone sdk programming with objectivec_部分3Tab Bar Applications ❘ 189 FIGURE 8-7 The Tab Bar Controller contains a collection of View Controllers. In this case, there are two view con- trollers contained within it. The fi rst view controller inside the UITabBarController instance is always displayed when it is added to the current view: - (void)applicationDidFinishLaunching:(UIApplication *)application {
// Add the tab bar controller's current view as a subview of the window [window addSubview:]; } When the user touches the Tab Bar items, each corresponding view controller is loaded to display its view. NOTE Another way to view the window is to switch it to display in List View (the second button at the top left corner of the window). Doing so allows you to quickly inspect the collection of View Controllers contained in the Tab Bar Controller. 190 ❘ CHAPTER 8 TAB BAR AND NAVIGATION APPLICATIONS Adding Tab Bar Items The previous section demonstrated how to create a Tab Bar application using the template provided by the SDK. By default, the application template includes only two Tab Bar items, so in this section, you see how to add more Tab Bar items to the existing Tab Bar. TRY IT OUT Adding Tab Bar Items 1. Using the same project, in Interface Builder, drag and drop a Tab Bar item from the Library onto the Tab Bar view (see Figure 8-8). FIGURE 8-8 2. Select the newly added Tab Bar item and view its Attributes Inspector window. Set the Badge property to 5 and the Identifi er property to Search. (see Figure 8-9). Observe the change in appearance of the Tab Bar item. NOTE Click the center of the Tab Bar item so that the Tab Bar item can be selected; if you click the outside, the View Controller is selected. Tab Bar Applications ❘ 191 FIGURE 8-9
【iphone开发书籍大全】 beginning iphone sdk programming with objectivec 部分3 来自淘豆网www.taodocs.com转载请标明出处.