-5

Goodevening

In IOS6.0 dismissModalViewControllerAnimated:(BOOL) is deprecated. Sadly i can't find any other solution on the internet. Anybody any toughts? I have a closebutton with a method. In that method the modalview should be closed.

Making of button:

    UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(200, 200, 50, 50)];
    closeBtn.backgroundColor = [UIColor purpleColor];
    [closeBtn addTarget:self action:@selector(closeModalView:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:closeBtn];

And the method:

     - (void)closeModalView:(id)sender{
          //This is deprecated
          [self dismissModalViewControllerAnimated:YES];
     }

Thx in advance!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Warre Buysse
  • 1,335
  • 4
  • 21
  • 39
  • "Sadly i can't find any other solution on the internet" Did you even try? This information is not exactly hiding. – matt Apr 29 '13 at 23:18
  • 3
    Why are you looking on the internet? How about the UIViewController Class Reference? Or how about the code completion in Xcode -- if you type self dismissMod..., by the time you get there, you'll get a popup showing you the correct method. – rdelmar Apr 29 '13 at 23:21

2 Answers2

4

New method:

[self dismissViewControllerAnimated:YES completion:nil];
iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
1

Use [self dismissViewControllerAnimated:YES completion:nil

Apple replaced the method so you can do things like show an alert view after the view has been dismissed:

[self dismissViewControllerAnimated:YES completion:^{
    [[[UIAlertView alloc] initWithTitle:..] show];
}];
Undo
  • 25,519
  • 37
  • 106
  • 129