故事板无法找到任何新的UIViewControllers

时间:2015-11-20 10:49:52

标签: ios storyboard

我正在用3个视图编写simle应用程序。我使用storyboard来制作我的观点。突然,storyboard停止发现任何新的UIViewController期望的两个,我添加了UINavigationController

当我将segue转移到另一个UIViewController时,app错误在运行时出现此类错误

2015-11-20 13:33:25.340 simplegram[8468:337685] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x7fcdf35fa150>) doesn't contain a view controller with identifier 'UIViewController-BYZ-38-t0r''
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010214af65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010183fdeb objc_exception_throw + 48
    2   UIKit                               0x0000000102bd95d4 -[UIStoryboard instantiateInitialViewController] + 0
    3   UIKit                               0x0000000102bddd11 -[UIStoryboardSegueTemplate instantiateOrFindDestinationViewControllerWithSender:] + 90
    4   UIKit                               0x0000000102bddf6e -[UIStoryboardSegueTemplate _perform:] + 52
    5   UIKit                               0x00000001026855e0 -[UIViewController performSegueWithIdentifier:sender:] + 99
    6   simplegram                          0x000000010131fb2f -[SGFeedTableViewController logInOrout:] + 223
    7   UIKit                               0x00000001024f91fa -[UIApplication sendAction:to:from:forEvent:] + 92
    8   UIKit                               0x000000010265d504 -[UIControl sendAction:to:forEvent:] + 67
    9   UIKit                               0x000000010265d7d0 -[UIControl _sendActionsForEvents:withEvent:] + 311
    10  UIKit                               0x000000010265c906 -[UIControl touchesEnded:withEvent:] + 601
    11  UIKit                               0x0000000102563aa3 -[UIWindow _sendTouchesForEvent:] + 835
    12  UIKit                               0x0000000102564691 -[UIWindow sendEvent:] + 865
    13  UIKit                               0x0000000102516752 -[UIApplication sendEvent:] + 263
    14  UIKit                               0x00000001024f1fcc _UIApplicationHandleEventQueue + 6693
    15  CoreFoundation                      0x00000001020770a1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    16  CoreFoundation                      0x000000010206cfcc __CFRunLoopDoSources0 + 556
    17  CoreFoundation                      0x000000010206c483 __CFRunLoopRun + 867
    18  CoreFoundation                      0x000000010206be98 CFRunLoopRunSpecific + 488
    19  GraphicsServices                    0x000000010586aad2 GSEventRunModal + 161
    20  UIKit                               0x00000001024f7676 UIApplicationMain + 171
    21  simplegram                          0x000000010132266f main + 111
    22  libdyld.dylib                       0x00000001047d692d start + 1
    23  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

但我有viewController这样的标识符。这是来自我的Main.storybord代码:

<!--Login View Controller-->
        <scene sceneID="tne-QT-ifu">
            <objects>
                <viewController id="BYZ-38-t0r" customClass="SGLoginViewController" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="chk-r5-USb"/>
                        <viewControllerLayoutGuide type="bottom" id="qah-gU-era"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
                        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TcZ-z2-At9">
                                <rect key="frame" x="-4" y="64" width="328" height="504"/>
                                <animations/>
                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                <connections>
                                    <outlet property="delegate" destination="BYZ-38-t0r" id="EDE-kc-95M"/>
                                </connections>
                            </webView>
                        </subviews>
                        <animations/>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                        <constraints>
                            <constraint firstItem="qah-gU-era" firstAttribute="top" secondItem="TcZ-z2-At9" secondAttribute="bottom" id="QWn-ma-ddG"/>
                            <constraint firstAttribute="trailingMargin" secondItem="TcZ-z2-At9" secondAttribute="trailing" constant="-20" id="XCZ-PP-bHL"/>
                            <constraint firstAttribute="leadingMargin" secondItem="TcZ-z2-At9" secondAttribute="leading" constant="20" id="wOA-BM-wCv"/>
                            <constraint firstItem="TcZ-z2-At9" firstAttribute="top" secondItem="chk-r5-USb" secondAttribute="bottom" id="wYh-hd-QJg"/>
                        </constraints>
                    </view>
                    <navigationItem key="navigationItem" id="qKX-a7-kaA"/>
                    <connections>
                        <outlet property="loginWebView" destination="TcZ-z2-At9" id="ZBa-cO-0sC"/>
                    </connections>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="161.59999999999999" y="377.71999999999997"/>
        </scene>

并从故事板中筛选出尽可能清晰的问题: problem with Login View Controller

执行此建议的代码:

- (IBAction)logInOrout:(id)sender {
    if ([self.api isSessionValid]) {
        [self.api logout];
    }
    else {
        [self performSegueWithIdentifier:@"login_segue" sender:self];
    }
}

我试图在没有任何代码的情况下执行segue,按住Ctrl键将它从故事板中的按钮拖动到目标视图控制器,但没有任何改变。

2 个答案:

答案 0 :(得分:1)

点击两个viewcontrollers之间的图标,然后在attribute inspector的右侧窗格中选择xcode

您会找到名称为identifier的字段。在该插入中,值为login_segue

清理并运行应用程序。

segue right pane

答案 1 :(得分:-1)

Storyboard Identifier在代码和界面构建器中检查您的故事板标识符。它们都应该匹配。否则storyboard将无法找到视图控制器。请看下面的例子。

示例:这个 PPHomeScreen *screen = [YourStoryboard instantiateViewControllerWithIdentifier:@"HomeScreen"];

接口构建器中的

和Storyboard Id(如图所示)应该相同。

希望解决你的问题。