1

I used to program in Objective-c, I used

UIStoryboard *FILLIN = [UIStoryboard storyboardWithName:@"FILLIN" bundle:nil];
UIViewController *FILLIN = [FILLIN instantiateViewControllerWithIdentifier:@"FILLIN"];
FILLIN.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:FILLIN animated:YES completion:nil];

but that doesn't work anymore. Also, when I try to use a modal to go the the view controller I want, it messes up and crashes. I am trying to get to the viewController from a button, and I also need to be able to go to different storyboards. If you could, i need to know how to do what my objective-c code did, but in swift. Thanks in advance for your help!

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
Mark Calhoun
  • 545
  • 1
  • 5
  • 10

1 Answers1

1

Assuming that your Objective-C code works, the relevant Swift code would look something like

let storyboard = UIStoryboard(name: "FILLIN", bundle: nil)
let viewController = storyboard.instantiateViewControllerWithIdentifier("FILLIN") as UIViewController // Explicit cast is required here.
viewController.modalTransitionStyle = .CoverVertical
self.presentViewController(viewController, animated: true, completion: nil)

You'd also have to make sure to import UIKit at the beginning of the file.

Kamaros
  • 4,536
  • 1
  • 24
  • 39
  • That works, but the same error is appearing, it says '[<_TtC12Fading_Light9nameEnter 0x1375063f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Every time i try to switch view controller it says this and crashes, do you know how i fix this? – Mark Calhoun Jul 29 '14 at 19:53
  • 1
    You should check if there is any invalid UI elements in your storyboard or xib file. http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant-for-the-key – Anthony Kong Jul 29 '14 at 19:55
  • THANK YOU SO MUCH!!!! Honestly, I can't thank you enough, i've been working on this for so many days! – Mark Calhoun Jul 29 '14 at 20:08