0

最初のView Controller

UIStoryBoard を使用して、FirstViewController が 2 番目の 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];

}

SecondViewController.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 に答える