sma*_*nja 6 iphone objective-c ios4 ios
在我的应用程序中有两个viewControllers FirstViewController和DetailViewController.当点击表格单元格时,它会导航到DetailViewController.在DetailViewController,我想编辑并重新加载FirstViewController的表视图
我NSNotification该如何使用这个问题?
这是我要实现的方法NSNotification的东西
-(IBAction) save{
strSelectedText=theTextField.text;
[NSNotificationCenter defaultCenter];
NSNotification* notification = [NSNotification notificationWithName:@"MyNotification" object:self];
[[NSNotificationCenter defaultCenter] postNotification:notification];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (objFirstViewController) name:@"MyNotification" object:nil];
[self.navigationController popViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
-(void)viewDidLoad {
[NSNotificationCenter defaultCenter];
NSNotification* notification = [NSNotification notificationWithName:@"MyNotification" object:self];
[[NSNotificationCenter defaultCenter] postNotification:notification];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (objFirstViewController) name:@"MyNotification" object:nil];
}
-(IBAction) save{
[[NSNotificationCenter defaultCenter] postNotificationName:MyNotification object:sender];
//this will go to where you implement your selector objFirstViewController.
}
-(void)objFirstViewController:(NSNotification *)notification {
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11246 次 |
| 最近记录: |