在Storyboard中以编程方式访问UIViewController

Dev*_*ali 1 iphone objective-c storyboard ios

我正在开发一个具有多个ViewControllers的应用程序,并且有一个特定的ViewController"登录ViewController",我想从几乎每个UIViewController访问它,我知道我可以通过使用segue从每个控制器到LoginViewController实现这一点,我我肯定不是最好的解决方案,实现这一目标的最佳解决方案是什么?

Lit*_*T.V 7

使用此...变量vc返回您正在寻找的viewcontroller

  UIStoryboard *aStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
  YourViewController *vc = [aStoryboard instantiateViewControllerWithIdentifier:@"YourViewController"];
Run Code Online (Sandbox Code Playgroud)