SoFunction
Updated on 2025-04-13

iOS page jump and data transfer (three types)

iOS page jump:

The first type

[ pushViewController:subTableViewController animated:YES];

//Description: Jump through NSNavigationBar

 [ popViewControllerAnimated:YES];

//Description: Return to the upper view in the subview

The second type

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

//Description: Jump through events

[self dismissModalViewControllerAnimated:YES];

//Description: Return through events.

The third type

[ addSubview:otherview];
[ removeFromSuperview]

Data delivery:

1) Use the proxy mode child viewcontroller to design the proxy protocol, define the protocol interface, and the parent viewcontroller implements the protocol interface, and implements the child viewcontroller to update the relevant data to the parent view when the child viewcontroller exits.
2) Adopt 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 listening, where setData is used to process messages

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

//Send a message

3) Use database as the storage medium between the data. The child viewcontroller stores the status data into the DB, and the parent viewcontroller obtains data from the DB and updates the view.

4) NSDefault storage using ios

5) Implement the storage of intermediate data by defining global variables in AppDelegate.

The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!