IPhone and iPad development practices-Analysis of iOS classic applications

Source: Internet
Author: User

3.3.2 view flip Animation

Click the button in the lower-right corner of the main view to flip the main view to the back view. Click the Done button in the back view to return to the main view. In iOS, this is a view jump Method with animation effects. In this application, a root controller is used to control the controller of other controllers) RootViewController to control the main View Controller MainViewController) and the behind View Controller FlipsideViewController ).
This application loads the RootViewController controller through the MainWindow. xib file, and then creates a MainViewController and FlipsideViewController in the RootViewController.
Double-click the MainWindow. xib window, as shown in Figure 3-25.




650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S13564R-0.jpg "title =" Click "Here To EnLarge" border = "0"/>
Figure 3-25 MainWindow. xib window
Double-click RootViewController in Figure 3-26 to open the root Controller Design view 3-26.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S1356014-1.jpg "title =" Click "Here To EnLarge" border = "0"/>
Figure 3-26 root Controller Design view
There is no corresponding view object when this root controller is created. We need to drag a UIView object from the object library, as shown in Figure 3-27. After dragging, the view is shown in 3-28.


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S1354393-2.jpg "title =" Click "Here To EnLarge" border = "0"/>
Figure 3-27 drag a View to the root Controller

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S135N24-3.jpg "title =" Click "Here To EnLarge" border = "0"/>
Figure 3-28 view After dragging
Open the Object Library) is opened through the menu Tools> Library.

You also need to add a button in Figure 3-28. This button is a special button. iOS provides a template for creating this button, first, you need to find the Rounded Rect Button in the object library and drag it to 3-29 in the lower left corner of the view.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S13534U-4.jpg "title =" Click "Here To EnLarge" border = "0"/>
Figure 3-29 drag a button
How can this button be changed to a button? Select a button and open the button checker in the menu Tools> Attributes Inspector, as shown in 3-30. In Figure 3-30, select Info Light from the Type drop-down list, in this way, the Oval Button above is changed to 3-31.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S1351540-5.jpg "title =" Click "Here To EnLarge" border = "0"/> Figure 3-30 property checker Figure 3-31 Info Light button
In Figure 3-30, there are many button types in the Type drop-down list, which are several template buttons defined by iOS. These buttons have this special meaning in iOS. If they are not really needed, they are generally not used easily. Is to display application information, which is generally used in practical applications. Apple guidelines and specifications for these buttons.

Now the peripheral work of view flip is basically completed. We can add code for the program. First, add RootViewController. h root controller h file such as "code list 3-1 Password/Classes/RootViewController. h.
Code List 3-1: Password/Classes/RootViewController. h
# Import <UIKit/UIKit. h>

@ Class MainViewController;
@ Class FlipsideViewController;

@ Interface RootViewController: UIViewController {

IBOutletUIButton * infoButton;
MainViewController * mainViewController;
FlipsideViewController * flipsideViewController;
UINavigationBar * flipsideNavigationBar;
}

@ Property (nonatomic, retain) UIButton * infoButton;
@ Property (nonatomic, retain) MainViewController * mainViewController;
@ Property (nonatomic, retain) UINavigationBar * flipsideNavigationBar;
@ Property (nonatomic, retain) FlipsideViewController * flipsideViewController;

-(IBAction) toggleView;

@ End
In the H file, you need to define the member variables, methods, and attributes. infoButton corresponds to the buttons in the view.
In addition to defining the output port for the control in the program, you also need to connect the control member variables of the output port defined in the View Controller or view with the control in the nib file, as shown in Figure 3-32, the connection process of the infoButton Control is to hold down the Control key and use the mouse to select the Root View Controller to drag the link to the infoButton Control, and then release the Control key to select the Control output port attribute, which is in MainWindow. the nib file of xib is connected in this way. If the MainView. xib File is shown in a general nib3-33, where the Controller name is File's Owner, you need to drag the File's Owner to the control. In general, the control of the output port is defined in the View Controller, but in this application, some controls are defined in the view, in this case, we need to drag the view object to the control, as shown in Figure 3-34.


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S13533Y-6.jpg "title =" Click "Here To EnLarge" border = "0"/>
Figure 3-32 controller and control output port connections

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S1354464-7.jpg "title =" Click "Here To EnLarge" border = "0"/>
Figure 3-33 connection between the MainView controller and the control output port

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/0S1356054-8.jpg "title =" Click "Here To EnLarge" border = "0"/>
Figure 3-34 connection between MainView and control output port
The mainViewController attribute is the main view controller, the flipsideViewController attribute is the View Controller behind the view, and the flipsideNavigationBar is the navigation bar control of the view behind the view. The toggleView method is an IBAction) method, indicating that it is connected with the control event. This method corresponds to the Click Event of the corresponding button.
The method for connecting IBAction Action events to the output port is similar. You must use Interface Builder to open the nib file. Interface Builder connects the control to the Controller or view, but the direction is opposite to that of the output port, the output port is connected by holding down the Control key and dragging the mouse from the Controller or view) to the Control, while the IBAction Action event is dragged from the Control to the Controller or view ).

This article from the "Guan Dongsheng" blog, please be sure to keep this source http://2009315319.blog.51cto.com/701759/882592

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.