场景无法访问...没有标识符
Scene is unreachable ... does not have an identifier
我收到此警告:
Scene is unreachable due to lack of entry points and does not have an
identifier for runtime access via - instaniateViewControllerWithIdentifier
虽然 Xcode 关于没有入口点是正确的,但它确实定义了以下内容:
Custom Class : Class = ViewControllerCatalog
Identify : Storyboard ID = vccatalog
我还需要定义什么来避免这个错误?
有两种方法可以过渡到情节提要中的场景:您可以转到它,也可以使用它的情节提要标识符实例化它。但是警告指出您既没有任何 segues 也没有故事板标识符,因此无法实例化该场景。您可以实例化基础 class,但除非您使用 instantiateViewControllerWithIdentifier
,否则无法使用故事板场景(及其所有控件以及所有 IBOutlet
和 IBAction
引用) .为了使用那个故事板方法,场景显然需要一个故事板标识符。
因此,如果您不打算使用转场,那一定意味着您将以编程方式过渡到该场景。所以,首先确保指定故事板标识符:
然后像这样实例化链接到该场景的 DetailsViewController
:
let controller = storyboard!.instantiateViewControllerWithIdentifier("DetailsScene") // or, if you need to access custom properties, `storyboard!.instantiateViewControllerWithIdentifier("DetailsScene") as! DetailsViewController`
// now use it as you see fit, e.g.,
//
// showViewController(controller, sender: self)
我收到此警告:
Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via - instaniateViewControllerWithIdentifier
虽然 Xcode 关于没有入口点是正确的,但它确实定义了以下内容:
Custom Class : Class = ViewControllerCatalog Identify : Storyboard ID = vccatalog
我还需要定义什么来避免这个错误?
有两种方法可以过渡到情节提要中的场景:您可以转到它,也可以使用它的情节提要标识符实例化它。但是警告指出您既没有任何 segues 也没有故事板标识符,因此无法实例化该场景。您可以实例化基础 class,但除非您使用 instantiateViewControllerWithIdentifier
,否则无法使用故事板场景(及其所有控件以及所有 IBOutlet
和 IBAction
引用) .为了使用那个故事板方法,场景显然需要一个故事板标识符。
因此,如果您不打算使用转场,那一定意味着您将以编程方式过渡到该场景。所以,首先确保指定故事板标识符:
然后像这样实例化链接到该场景的 DetailsViewController
:
let controller = storyboard!.instantiateViewControllerWithIdentifier("DetailsScene") // or, if you need to access custom properties, `storyboard!.instantiateViewControllerWithIdentifier("DetailsScene") as! DetailsViewController`
// now use it as you see fit, e.g.,
//
// showViewController(controller, sender: self)