0

第一个视图控制器

我正在使用 UIStoryBoard 来允许 FirstViewController 将第二个 ViewController 的视图添加为子视图。在删除子视图时

  - (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];

}

第二视图控制器.m

-(void)viewDidLoad{
   self.view.opaque = YES;
   self.view.backgroundColor = [UIColor clearColor];
}

 - (IBAction) withDraw:(id)sender{
     [self.view removeWithZoomOutAnimation:2 option:nil];
    }

当我访问 withDraw 函数时,SecondViewController 的视图被删除并且 firstViewController 又回来了。但是,当我使用按钮访问 - (IBAction) btnMoveTo:(id)sender 函数时。它不起作用。什么都没有发生。任何建议或帮助将不胜感激。

4

2 回答 2

0

有效

- (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];
}

我通过指向它的标识符添加了 firstViewController 的另一个实例。所以它将 FirstViewController 带回顶部。

于 2012-07-12T03:29:38.193 回答
0

也许您可以尝试像这样声明 *vc: UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"Second"];

于 2012-07-12T03:21:40.707 回答