A brief summary of Ios:ui

Source: Internet
Author: User

Simple UI Summary:

First, the common single case:

NSBundle *bundel = [NSBundle mainbundle]; Load Resources

Nsfilemanager *FM = [Nsfilemanager defaultmanager];//file Management

UIApplication *app = [UIApplication Sharedapplication];//app Object

UIScreen *screen = [uiscreen mainscreen];//screen

Nsnotificationcenter *center = [nsnotificationcenter defaultcenter];//Notification Center

Second, commonly used agents:

text box:<UITextFieldDelegate>

text view: <UITextViewDelegate>

table View:<UITableViewDelegate>, <UITableViewDataSource>

Collection View:<uicollectionviewdelegate>, <UICollectionViewDatasource>

scrolling View:<UIScrollViewDelegate>

Search bar:<UISearchBarDelegate>, <UISearchDisplayDelegate>

Third, view switch mode:

1. Modal window (modal: Modal)

(1) When there is no segue connection between the controllers, obtain the destination controller to switch to and switch the view method to:

Get the story board you are on

+ (Uistoryboard *) Storyboardwithname: (NSString *) name Bundle: (NSBundle *) Storyboardbundleornil;

The storyboard object obtains the destination controller through the identity of the destination controller Storyboardid

-(ID) Instantiateviewcontrollerwithidentifier: (NSString *) identifier;

Display the modal window of the destination controller in the source controller

-(void) Presentviewcontroller: (Uiviewcontroller *) viewcontrollertopresent animated: (BOOL) flag completion: (void (^) ( void)) completion;

To close the modal window of the current controller in the destination controller

-(void) dismissviewcontrolleranimated: (BOOL) animated;

As follows:

In the source controller:

Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Main" bundle:nil];

Destinationviewcontroller *desvc= [Storyboard instantiateviewcontrollerwithidentifier:@ "DEVC"];

[Self presentviewcontroller:desvc animate:yes completion:nil];//mode out the window of the destination controller

The purpose of the controller:

Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Main" bundle:nil];

Resourceviewcontroller *resvc = [Storyboard instantiateviewcontrollerwithidentifier:@ "REVC"];

[Self.presentingviewcontroller dismissviewcontrolleranimated:yes];//Current controller close modal window

or (if write self calls the method, the default is Self.presentingviewcontroller calls the method)

[Self Dissmissviewcontrolleranimated:yes]

(2) when the controller is connected through a Segue , obtain the destination controller to switch to and switch the view method to: First set the identifier identity to segue in the storyboard , and then use the following method.

When triggering an event, you can jump to the destination controller interface directly according to the Segue identifier

-(void) Performseguewithidentifier: (NSString *) identifier sender: (ID) sender;

This method can be overridden, the method is automatically called when the view is toggled, can be used to forward data, or can be obtained to the destination controller

-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) sender;

as follows:

After connecting the destination controller via segue, if the Segue identifier identifier is DEVC, the jump view is:

[Self PERFORMSEGUEWITHIDENTIFIER:DEVC sender:self];//switch to the view of the destination control

When the view is toggled, override this method to obtain the destination controller and transmit data, still assuming that the identifier for the Segue identifier is DEVC

-(void) Prepareforsugue: (uistoryboardsegue *) identifier sender: (ID) sender

{

if ([Segue.identifier ISEQUALTOSTRING:DEVC])

{

Destinationviewcontroller *desvc = segue.destinationviewcontroller;//Get the destination controller

Desvc.info = self. textfield.text;//data from the current controller to the destination controller

}

}

2, Uinavigationcontroller (push: Into the stack pop: out of the stack), provided that the Uinavigationcontroller controller container must exist first, and then add a root controller at the bottom of it, as the first display of the view, If the other view is displayed, the destination controller is pressed into the stack, and the stack is rolled out instead.

(1) when there is no segue connection between the controllers , obtain the destination controller to switch to and switch the view method to:

Get the story board you are on

+ (Uistoryboard *) Storyboardwithname: (NSString *) name Bundle: (NSBundle *) Storyboardbundleornil;

The storyboard object obtains the destination controller through the identity of the destination controller Storyboardid

-(ID) Instantiateviewcontrollerwithidentifier: (NSString *) identifier;

Press the destination controller into the stack, which is the view of the destination controller

-(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated;

Pushes the top controller out of the stack, showing the view of its previous controller

-(Uiviewcontroller *) popviewcontrolleranimated: (BOOL) animated;

Returns the specified sub-controller (the controller above it is rolled out of the stack, showing its view)

-(Nsarray *) Poptoviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated;

Returns the root controller (view showing the controller at the bottom of the stack)

-(Nsarray *) poptorootviewcontrolleranimated: (BOOL) animated;

As follows:

In the source controller:

Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Main" bundle:nil];

Destinationviewcontroller *desvc= [Storyboard instantiateviewcontrollerwithidentifier:@ "DEVC"];

[Self.navigationcontroller PUSHVIEWCONTROLLER:DEVC animate:yes];//pushes the destination controller into the stack, which displays

The purpose of the controller:

[Self.navigationcontroller popviewcontrolleranimated:yes];//the controller of the currently displayed view in the stack, which displays the view of the previous controller

(2) when the controller is connected through a Segue , obtain the destination controller to switch to and switch the view method to: First set the identifier identity to segue in the storyboard , and then use the following method.

When triggering an event, you can jump to the destination controller interface directly according to the Segue identifier

-(void) Performseguewithidentifier: (NSString *) identifier sender: (ID) sender;

This method can be overridden, the method is automatically called when the view is toggled, can be used to forward data, or can be obtained to the destination controller

-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) sender;

as follows:

After connecting the destination controller via segue, if the Segue identifier identifier is DEVC, the jump view is:

[Self PERFORMSEGUEWITHIDENTIFIER:DEVC sender:self];//switch to the view of the destination control

When the view is toggled, override this method to obtain the destination controller and transmit data, still assuming that the identifier for the Segue identifier is DEVC

-(void) Prepareforsugue: (uistoryboardsegue *) identifier sender: (ID) sender

{

if ([Segue.identifier ISEQUALTOSTRING:DEVC])

{

Destinationviewcontroller *desvc = segue.destinationviewcontroller;//Get the destination controller

Desvc.info = self. textfield.text;//data from the current controller to the destination controller

}

}

3, Uitabbarcontroller

A brief summary of Ios:ui

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.