Home >Web Front-end >HTML Tutorial >Several page jumps and value passing (notification value passing)_html/css_WEB-ITnose
A→B→C→D→A
A is not the root directory, but it needs to jump back to D without alloc. In this case, we can use the following Method
[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: ([self.navigationController.viewControllers count] -4)] animated:YES];
And D wants to pass a value to A, then notification is very useful
Notification passing value (one sender, a bunch of receivers, no proxy protocol is required, directly through the system’s notification center Work notificationCenter)
On the value transfer page
First get a system notification center
NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
NSNotification * notify = [NSNotification notificationWithName:@"regisonName" object:[NSString stringWithFormat:@"%@",[self.dataArray[indexPath.row] objectForKey:@"name"]]];
// The first parameter is the name of the notification, which is the label. Give it a name in case you use this name to find the object. The second parameter is the value you want to pass and the value you want to receive. This value must be an object
[center postNotification:notify];
On the receiving page
//NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
[[NSNotificationCenter defaultCenter] addObserver:self
:@"regisonName"
- (void)setRegionTitle:(NSNotification *)notify{
NSString * object = [notify object];
[_regionButton setTitle:object forState:UIControlStateNormal]; [_regionButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
}