我只是想知道在我解雇之后是否可以推送到ViewController.
我一直在尝试这个:
-(void)dismiss{
//send information to database here
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"Dismiss completed");
[self pushtoSingle:post_id];
}];
}
-(void)pushtoSingle:(int)post_id{
Single1ViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:@"SingleView"];
svc.post_id = post_id;
svc.page = 998;
[self.navigationController pushViewController:svc animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
还有这个:
-(void)dismiss{
//send information to database here
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"Dismiss completed");
Single1ViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:@"SingleView"];
svc.post_id = post_id;
svc.page = 998;
[self.navigationController pushViewController:svc animated:YES];
}];
}
Run Code Online (Sandbox Code Playgroud)
但没有成功.视图成功被取消,但推送从未初始化.是否有其他已知方法解决问题?
278*_*204 29
是的,我明白了.在我将ViewController B解除为A然后在A中收到通知并推送到C之后,我只是发布了一个通知.
解雇B:
[self dismissViewControllerAnimated:YES completion:^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushToSingle" object:nil userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:post_id1] forKey:@"post_id"]];
}];
Run Code Online (Sandbox Code Playgroud)
在A中接收:
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushToSingle:) name:@"pushToSingle" object:nil];
}
-(void)pushToSingle:(NSNotification *)notis{
NSDictionary *dict = notis.userInfo;
int post_id = [[dict objectForKey:@"post_id"] intValue];
NSLog(@"pushing to single");
Single1ViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:@"SingleView"];
svc.post_id = post_id;
svc.page = 998;
[self.navigationController pushViewController:svc animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
谢谢,Jacky Boy!
| 归档时间: |
|
| 查看次数: |
28917 次 |
| 最近记录: |