Sib*_*san 3 xcode storyboard ios uistoryboardsegue
我在标签栏控制器之前有一个页面(比如说X),它使用模型segue来打开标签栏控制器.标签栏控制器的第一个屏幕与X相同.
我想将数据从X传递到标签栏控制器的第一页.
不久,我想通过storyboard segue将数据从视图控制器传递到标签栏控制器页面.这有什么方法吗?
这是解决方案;
locationsHome* vc = [[locationsHome alloc] init];
UITabBarController* tbc = [segue destinationViewController];
vc = (locationsHome *)[[tbc customizableViewControllers] objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)
这就是我解决问题的方法.您可以使用此方法将数据从ViewController传递到TabBarController.
在prepareForSegue方法中使用此代码
locationsHome* vc = [[locationsHome alloc] init];
UITabBarController* tbc = [segue destinationViewController];
vc = (locationsHome *)[[tbc customizableViewControllers] objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)
像这样:
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSString * segueIdentifier = [segue identifier];
if([segueIdentifier isEqualToString:@"tabbarGo"]){
locationsHome* vc = [[locationsHome alloc] init];
UITabBarController* tbc = [segue destinationViewController];
vc = (locationsHome *)[[tbc customizableViewControllers] objectAtIndex:0];
etc...
}
}
Run Code Online (Sandbox Code Playgroud)