didSelectRowAtIndexPath Segue Not Sending

时间:2015-11-11 12:23:37

标签: swift swift2 uistoryboard uistoryboardsegue appdelegate

更新的问题

当下面的代码处于活动状态时,我的应用程序中的AppDelegate中的代码崩溃/不会识别在MainStoryBoard中进行segue时的segue。

在我的AppDelegate中,我在didFinishLaunchingWithOptions中添加以下代码行来设置标题。但是,我无法删除代码,否则我将没有标题,不幸的是它需要它是rootViewController。有什么建议如何改写这个? :

   var tableVC:FeedTableViewController = FeedTableViewController(className: "ProductInfo")

        let headerImage = UIImage(named:"header.png")
        UINavigationBar.appearance().setBackgroundImage(headerImage, forBarMetrics:.Default)
 UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.Default

        var navigationVC:UINavigationController = UINavigationController(rootViewController: tableVC)



       let frame = UIScreen.mainScreen().bounds
        window = UIWindow(frame: frame)

        window!.rootViewController = navigationVC
       window!.makeKeyAndVisible()

当我拿出定义rootVC等的window代码时,我能够毫无问题地进行调整。我在appDelegate中设置的标题也会消失。

我在崩溃时遇到的错误是接收器VC没有名为“mySegue”的segue。接收器VC应该是我的初始VC,并被设置为故事板中的初始VC。

正在对didSelectRowAtIndexPath执行segue。

为什么?有任何想法吗?

提前谢谢。

1 个答案:

答案 0 :(得分:0)

你弄错了。出列仅用于在<application android:allowBackup="true" android:icon="@mipmap/ic_resqlife_logo" android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name=".SplashScreen" android:label="@string/app_name" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".UserChoice" android:label="@string/title_activity_user_choice" android:screenOrientation="portrait" > </activity> <activity android:name=".RegFormActivity" android:label="@string/title_activity_reg_form" android:screenOrientation="portrait" > </activity> <activity android:name=".OTPVerificationActivity" android:label="@string/title_activity_otpverification" android:screenOrientation="portrait" > </activity> <activity android:name=".MainActivity" android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait" > </activity> <service android:name=".GcmIntentService" android:exported="true" > </service> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="@string/google_maps_key" /> <activity android:name=".MapsActivity" android:label="@string/title_activity_maps" android:screenOrientation="portrait" > </activity> <activity android:name=".GooglePlayServicesActivity" android:label="@string/title_activity_google_play_services" android:screenOrientation="portrait" > </activity> <activity android:name=".ContactsListActivity" android:label="" android:screenOrientation="portrait" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" /> </activity> <receiver android:name=".GcmBroadcastReceiver" android:enabled="true" android:exported="true" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.example.gcm" /> </intent-filter> </receiver> <activity android:name=".AlertActivity" android:configChanges="orientation|keyboardHidden|keyboard" android:label="@string/title_activity_alert" android:screenOrientation="portrait" > </activity> <service android:name=".LocationService" android:exported="true" > </service> <activity android:name=".NetworkActivity" android:label="@string/title_activity_network" android:screenOrientation="portrait" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" /> </activity> <activity android:name=".UpdateNetworkActivity" android:label="@string/title_activity_update_network" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".NetworkActivity" /> </activity> <receiver android:name=".ReregisterGCMReceiver" android:enabled="true" android:exported="true" > <intent-filter> <action android:name="android.intent.action.PACKAGE_REPLACED" /> <data android:path="com.tpl.arpitgoyal.resqlife" android:scheme="package" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <activity android:name=".UpdateProfile" android:label="@string/title_activity_update_profile" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" /> </activity> <activity android:name=".NoInternetActivity" android:label="@string/title_activity_no_internet" android:launchMode="singleTask" > </activity> <activity android:name=".InviteActivity" android:label="@string/title_activity_invite" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" /> </activity> <activity android:name=".CoordinatesActivity" android:label="@string/title_activity_coordinates" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="maps.google.com" /> <data android:scheme="https" /> <data android:pathPattern="/.*" /> </intent-filter> </activity> <!-- <receiver android:name=".UnInstallReceiver" android:enabled="true" android:exported="true" > <intent-filter> <action android:name="android.intent.action.PACKAGE_REMOVED" /> <data android:path="com.tpl.arpitgoyal.resqlife" android:scheme="package" /> </intent-filter> </receiver> --> <activity android:name=".SliderButtonActivity" android:label="@string/title_activity_slider_button" > </activity> <service android:name=".VibratorService" android:exported="true" > </service> <activity android:name=".SmsOTPVerificationActivity" android:label="@string/title_activity_sms_otpverification" > </activity> <service android:name=".OnLineService" android:enabled="true" android:exported="false" > </service> </application> 中创建单元格。要创建单元格,请使用cellForRowAtIndexPath

cellForRowAtIndexPath中,您只需致电didSelectRowAtIndexPath即可。

在准备segue时,您可以使用performSegue通知目标控制器它需要知道的任何数据。

更好:不是从控制器符号拖动segue,而是从单元本身拖动。然后,您根本不需要indexPath,但可以处理didSelectRowAtIndexPath中的所有逻辑。

prepareForSegue将成为单元格,您可以使用sender获取indexPath。