3

Is it possible to dismiss a Modal View Controller (e.g. Page Curl) just in Interface Builder?

My current approach always was to create a new ViewController subclass with an IBAction dismissModalViewController and I was wondering if I could save some space / time doing this step just in IB.

DAS
  • 1,941
  • 2
  • 27
  • 38

1 Answers1

8

No you cannot, because the Interface builder is simply a layout file, which doesn't run any code.

However you can create a custom UIButton subclass if you like and set that button to always dismiss the modal view controller when it is clicked. So whenever you need to dismiss a modal view controller, you can add in your IB a UIButton that is set to be a class of your created subclass and it will do the work for you.

Lefteris
  • 14,550
  • 2
  • 56
  • 95
  • OK, thanks for that idea. Doing (modal) segues is possible, so why not dismissing ViewControllers? – DAS Jan 01 '13 at 15:17
  • This is by design. See this SO question about this: http://stackoverflow.com/questions/9382099/ios-storyboarding-dismissing-a-modal – Lefteris Jan 01 '13 at 18:48
  • 1
    http://stackoverflow.com/questions/12569316/does-anyone-know-what-the-new-exit-icon-is-used-for-when-editing-storyboards-usi – DAS Jan 02 '13 at 06:58