0

DismissViewController UIButton causes my app to crash when testing on iPod touch. Otherwise, it is working fine on iPhone. iPod version is 4.2.1.

The message I am getting is:

dismissViewControllerAnimated:completion:]: unrecognized selector sent to instance 0x153720'

-(void)dismissViewDidFinish:(UIViewController *)viewController 
{

[self dismissViewControllerAnimated:YES completion:nil];

}    

This is the modalviewcontroller h file:

@class Info;

@protocol InfoDelegate 

-(void)dismissViewDidFinish:(UIViewController *)viewController;

@end
Shahbaz
  • 46,337
  • 19
  • 116
  • 182
user1452248
  • 767
  • 2
  • 11
  • 28

2 Answers2

2

You are getting the warning in yellow

Instance method -dismissViewController not found return type defaults to id –

because the old deprecated method, dismissModalViewController didnt require the 'completion:' param

The new method in iOS6 does. So you should write instead:

[self dismissViewControllerAnimated:YES completion:nil];

and it will find it

Alan
  • 692
  • 1
  • 7
  • 16
1

Where is the method "dismissViewController" defined? It's not a framework method. If you've used code from an example, be sure you define the method where you intend to. It is not a method on UIViewController.

If you are trying to dismiss a modal view controller, from the modal view controller, the way to do it is:

[self dismissModalViewControllerAnimated:YES];
Andy Obusek
  • 12,614
  • 4
  • 41
  • 62
  • it gives me warning in yellow that Instance method -dismissViewController not found return type defaults to id – user1452248 Jun 12 '12 at 21:36
  • What class is the method dismissViewDidFinish defined in? – Andy Obusek Jun 12 '12 at 21:39
  • What is "self" ? Where is dismissViewControllerAnimated defined? – Andy Obusek Jun 12 '12 at 21:40
  • it is defined in the mainviewcontroller the one which is presenting modalviewcontroller. Sorry it is defined in the info controller – user1452248 Jun 12 '12 at 21:42
  • Please post the code (and the class name where it's located) for the method "dismissViewControllerAnimated" Alternatively, if you are trying to dismiss a modal view controller, see my updated answer. – Andy Obusek Jun 12 '12 at 21:46
  • still crazing app and giving message [MainViewController presentingViewController]: unrecognized selector sent to instance 0x146e80 – user1452248 Jun 12 '12 at 21:49
  • You did not post the implementation of "dismissViewControllerAnimated"!!!! It's not a method defined on UIViewController, so if you didn't write it, it doesn't exist. I'm trying to read between the lines of your posts to figure out what's really going on. Did you present a modal view controller, and you are trying to dismiss that? If the modal view controller was presented from MainViewController, see my updated answer, and try it. – Andy Obusek Jun 12 '12 at 21:58
  • Thanks it worked now i have to check on iPhone also to see if it works over there too. – user1452248 Jun 12 '12 at 22:01