在這裏你可以委託方法做
//這是你的根視圖控制器調用委託方法
#import "ThirdViewController.h"
#import "SecondViewController.h"
@interface ViewController()<ThirdViewControllerDelegate>
@end
@implementation ViewController
#pragma mark -
#pragma mark ThirdViewController Delegate Method
//在你的根視圖控制器
委託方法實現
-(void)didSelectValue:(NSString *)value{
NSLog(@"%@",value);
}
// Pass the last Vc delegate to the next ViewController
-(void)gotoSeconddVc{
SecondViewController *vc2=[[SecondViewController alloc]init];
vc2.lastDelegate=self;
[self.navigationController pushViewController:vc2 animated:YES];
}
#import "ThirdViewController.h"
@interface SecondViewController : UIViewController
@property(nonatomic,retain) id <ThirdViewControllerDelegate> lastDelegate;
@end
-(void)gotoThirdVc{
ThirdViewController *vc3=[[ThirdViewController alloc]init];
vc3.delegate=self.lastDelegate;
[self.navigationController pushViewController:vc3 animated:YES];
}
最後視圖 - 控制
@implementation ThirdViewController
-(void)btnDoneClicked{
[self.navigationController popToRootViewControllerAnimated:YES];
[self.delegate didSelectValue:strValue]; //call delegate methods here
}
使用單例類的實現從lastView控制器先分享信息。 –
您也將使用NSNotificationCenter將數據發送到任何正在運行的視圖控制器。 – Natarajan
在這種情況下使用localNotification共享信息 – Mani