Return 故事板当前视图控制器标识符

Return storyboard current view controller identifier

如何找到实例化的当前视图控制器的标识符?

示例:

self.storyboard?.instantiateViewControllerWithIdentifier("ThisViewController") as! UIPageViewController

然后使用 self.storyboard?.currentViewControllerIdentifier 到 return ThisViewController?

来自 UIStoryboard 的文档:

This identifier is not a property of the view controller object itself and is used only by the storyboard file to locate the view controller.

所以简短的回答是你不能。更长的答案是您可以子类化 UIViewController 并为标识符添加一个 属性 并在每次从故事板加载时分配它。