[英]FirstViewController doesn't work on removing the subview of SecondViewController
First View Controller 第一视图控制器
I'm using a UIStoryBoard to allow the FirstViewController to add the view of second ViewController as a subview. 我正在使用UIStoryBoard允许FirstViewController将第二个ViewController的视图添加为子视图。 On removing the sub view the
在删除子视图时
- (IBAction) btnMoveTo:(id)sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"Second"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:vc animated:NO];
}
SecondViewController.m SecondViewController.m
-(void)viewDidLoad{
self.view.opaque = YES;
self.view.backgroundColor = [UIColor clearColor];
}
- (IBAction) withDraw:(id)sender{
[self.view removeWithZoomOutAnimation:2 option:nil];
}
When I access the withDraw Function, the view of the SecondViewController is removed and firstViewController is back. 当我访问withDraw函数时,SecondViewController的视图将被删除,并且firstViewController将返回。 However when I use the button to access the - (IBAction) btnMoveTo:(id)sender function.
但是,当我使用按钮访问-(IBAction)btnMoveTo:(id)sender函数时。 It doesn't work.
没用 Nothing really happens.
真的什么都没发生。 Any suggestions or help would be greatly appreciated.
任何建议或帮助将不胜感激。
也许您可以尝试这样声明* vc:UIViewController * vc = [self.storyboard InstantiateViewControllerWithIdentifier:@“ Second”];
It worked 有效
- (IBAction) withDraw:(id)sender{
[self.view removeWithZoomOViewControllerutAnimation:2 option:nil];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"First"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:vc animated:NO];
}
I added another instance of the firstViewController by pointing to its identifier. 我通过指向其标识符添加了firstViewController的另一个实例。 So it brings back FirstViewController to the top.
因此,它将FirstViewController带回到顶部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.