iOS Page Jump and Data Transfer (Three Kinds)

  • 2021-12-12 10:05:11
  • OfStack

iOS page jump:

Type 1

[self.navigationController pushViewController:subTableViewController animated:YES];

//Description: Jump through NSNavigationBar

 [self.navigationController popViewControllerAnimated:YES];

//Description: Return to parent view in child view

Type 2


UIViewController *control = [[UIViewController alloc] init]; [self presentModalViewController:control animated:YES]; [control release]; 

//Description: Jump through events

[self dismissModalViewControllerAnimated:YES];

//Description: Returns by event.

Type 3


[self.view.window addSubview:otherview];
[self.view removeFromSuperview]

Data transfer:

1) Proxy protocol is designed by proxy mode sub-viewcontroller and protocol interface is defined. Parent viewcontroller implements protocol interface and updates related data to parent view when sub-viewcontroller exits.
2) Using the message mechanism of ios, the parent viewcontroller registers the message, and the child viewcontroller sends the message to trigger the message processing of the parent viewcontroller.


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setData:) name:kNotificationMessage object:nil];

//Register listeners where setData is used to process messages


[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationMessage object:self userInfo:infoDict];

//Send a message

3) The database is used as the data intermediate storage medium, the child viewcontroller stores the state data into the DB, and the parent viewcontroller obtains the data from the DB to update the view.

4) NSDefault storage with ios

5) The storage of intermediate data is realized by defining global variables in AppDelegate.


Related articles: