简体   繁体   中英

how to get a viewcontroller's storyboard id/name

In my app, there are three storyboard. What I'd like to know is how to get a storyboard id/name in a viewcontroller code since UIStoryBoard init func takes first parameter name: String. where it stored and how to access it?

The storyboard name is the name of the .storyboard file itself, but without the .storyboard extension.

The UIViewController 's storyboard ID cannot be gotten, unless you have the restoration ID set to the storyboard ID and then you use

self.restorationIdentifier

不使用私有 API 就不可能获得故事板的名称。

To get the name of a storyboard, just go to your storyboard file, and don't click on any of the View Controllers. Open up the File Inspector, and on the first tab, at the top it will have your name (ie. "Main.storyboard"). It's also just the file name typically. However, the best way to get at a storyboard is just to get at the storyboard property.

您可以使用self.title来获取 ViewController 的名称

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM