ios7.0 combined with Storyborad to achieve page jump summary

Source: Internet
Author: User

Toss it all day, this article summarizes the content of ios7.0 page jump

The unspoken rules of storyboard

I contacted iOS very late and the environment was already xcode5+ios7, so I didn't know about the previous iOS development model. Read a lot of information on the Internet, found that the previous code, many need their own coding to create Viewcontroller, such as:

OBJC Code   
    1. Wtwoviewcontroller *controller = [[Wtwoviewcontroller alloc]initwithnibname:@"Wtwoviewcontroller" bundle:nil];
    2. [Self Presentviewcontroller:controller animated:yes completion:nil];


But with storyboard to manage the view controller, storyboard automatically handles the initialization of the view controller, so you no longer need to coding yourself to create an instance of the view controller. See this sentence in another blog post:

" people who have used xib I believe many people will often use -presentmodalviewcontroller:animated: and -pushviewcontroller:animated: these two methods. This code will become a history in the storyboard , instead of segue "

Control-based jumps

Use storyboard to do development, often need pull line, this article does not introduce, please read this official document:

Start developing IOS app today

This pull is pulled from the button to the View controller:

This way, just click on the button, will automatically jump, do not need to write any code

Direct from controller to controller this pull line is directly from the view controller to the View controller: This way has been pre-created segue, but also need to manually code, First you need to set an identity to segue and then write code to jump: OBJC code   
    1. Jump to Bootstrap
    2. -(void) jumptobootstrap{
    3. [Self performseguewithidentifier:@"Fromwelcometobootstrap" sender:self];
    4. }
This code must be written in the-viewdidappear, cannot be written in the-viewdidload, otherwise it will be reported an error: Whose view isn't in window hierarchy! Page transfer value before using-presentmodalviewcontroller:animated: method to jump, generally need to pass the value through delegate, etc., now all with Segue API can be done before segue happen, First call the current View controller's-prepareforsegue:sender: method, you can do some processing inside, such as: OBJC code   
    1. bootstrapviewcontroller* Targetcontroller = [Segue destinationviewcontroller];//get the target view controller, and then everything is okay.
It is important to note, however, that the view of the destination view controller cannot be set in the Prepareforsegue method because the view is not instantiated by storyboard at this time. But you can first pass the argument, and then set up another online to see a lot of posts, said from B back to a when you need to pass value, you can set A to B DELEGATE:OBJC code  
    1. Bviewcontroller.delegate = self;
Here I do not understand, when from B back to A, also set a segue seems to be the line unwind Segue unwind Segue is special, is in the target view controller first set an action, and then in the Source view Drag the line to the exit icon in the controller. In this case, the action of the target View controller will be invoked in addition to the Prepareforsegue method that invokes the source.

ios7.0 combined with Storyborad to achieve page jump summary

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.