您好我有一个关于segue的问题,我在这里查了很多帖子,并且很确定我已经正确设置了segue。这里是我的故事板XML,有两个场景,SplashScreen和ViewController。初始屏幕有一个称为“startSegue” SEGUE从XML看出:Segue在XML中找到,但没有在代码中找到
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
</dependencies>
<scenes>
<!--Splash Screen-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController autoresizesArchivedViewToFullSize="NO" automaticallyAdjustsScrollViewInsets="NO" modalTransitionStyle="crossDissolve" id="BYZ-38-t0r" customClass="SplashScreen" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="YHw-QP-f7w"/>
<viewControllerLayoutGuide type="bottom" id="2PH-gO-d5q"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="CXr-Vc-KGH">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<extendedEdge key="edgesForExtendedLayout"/>
<connections>
<segue destination="dqe-cT-PeC" kind="push" identifier="startSegue" id="bcv-Eq-8U6"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="306" y="314"/>
</scene>
<!--View Controller-->
<scene sceneID="Pnt-X0-2I5">
<objects>
<viewController id="dqe-cT-PeC" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="w8K-7E-bqp"/>
<viewControllerLayoutGuide type="bottom" id="Nj4-1u-ozE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="r7Q-nY-3Gv">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yAf-Ru-F3U" customClass="PreviewView">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="F3Y-vZ-LGa"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="n7E-NZ-nYo" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1021" y="314"/>
</scene>
</scenes>
</document>
但是当我调用的代码来执行SEGUE,它得到一个错误,并且所述“接收器()具有标识符没有SEGUE” startSegue ''
[self performSegueWithIdentifier: @"startSegue" sender: self];
使用try-catch对检查,它与navigationController问题无关。
BTW我设置在AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[SplashScreen alloc] initWithNibName:@"SplashScreen" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
任何提示用下面的代码的闪屏,将不胜感激!
你是否从SplashScreen类中调用performSegueWithIdentifier? –
您的XML文件是一个Storyboard文件。要加载初始控制器,应该使用[[UIStoryboard storyboardWithName:@“name”bundle:[NSBundle mainBundle]] instantiateInitialViewController]; –
谢谢!我没有测试你的建议,下面的答案工作正常(删除所有的init代码)感谢您的帮助! –