As a note written by a novice, it is convenient for your memory:
I have found a lot of information about the page redirection from Android to iOS. Now I will record the method of page redirection.
1. Use navigationController
2. Jump directly (I just found it online, I am not familiar with it, don’t blame me for any mistakes)
1. Create a RootViewController,
@property (strong, nonatomic) UIViewController *viewController;
@property (strong, nonatomic) UINavigationController *navController;
Code written in the didFinishLaunchingWithOptions function:
RootViewController *rootView = [[RootViewController alloc] init];
= @"Root View";
= [[UINavigationController alloc] init];
[ pushViewController:rootView animated:YES];
[ addSubview:];
These codes load the first page, RootViewController.
Jump to another page (such as SubViewController) code:
SubViewController *subView = [[SubViewController alloc] init];
[ pushViewController:subView animated:YES];
= @"Sub";
This benefit is that the return button will be automatically generated.
2. Jump directly, nothing
Don't do anything else, just create a new view object
SubViewController *subView = [[SubViewController alloc] initWithNibName:@"SubViewController" bundle:[NSBundle mainBundle]];
[self presentModalViewController:subView animated:YES];
That's fine.
This function will not be used after iOS 6.0
[self presentModalViewController:subView animated:YES];
Can be replaced
[self presentViewController:subView animated:YES completion:nil];
Data transfer when page jumps
For example, when you need to implement view1 to jump to view2, pass some data from view1 to view2.
Ideas:
1. Customize a bean class user, and implement user as a member variable in view2.
2. When view1 jumps, encapsulates the data as a user and assigns the value to
Code
1. view2
.h declares member variables
@property (strong, nonatomic) User *user;
2. view1
View2 *view2 = [[View2 alloc] init];
User *user = [[User alloc] init];
= @"kevin";
= user;
[ pushViewController: view2
animated:YES];
3. view2
Get variable