'Receiver has no segue with identifier' when identifier exists

前端 未结 1 1184
旧时难觅i
旧时难觅i 2021-01-03 11:20

For an iOS app, I have a story board and multiple controllers, and a segue going from controller GameClass to controller SettingsClass. The

1条回答
  •  悲哀的现实
    2021-01-03 11:37

    You should not instantiate your view controller this way:

    GameClass *myNewVC = [[GameClass alloc] init];
    

    Instead, use

     [[UIStoryboard storyboardWithName:@"storyboard name" bundle:nil] instantiateViewControllerWithIdentifier:@"vc identifier">]
    

    Edit: Take a look at https://github.com/mac-cain13/R.swift

    It will allow you to instantiate it easily with autocompletion, type safe method: R.storyboard.main.myViewController

    0 讨论(0)
提交回复
热议问题