亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

iOS-如何使用Swift快速編程選擇

iOS-如何使用Swift快速編程選擇

iOS
楊__羊羊 2019-10-15 13:57:35
我正在創建一個使用Facebook SDK來驗證用戶身份的應用程序。我正在嘗試將Facebook邏輯合并到一個單獨的類中。這是代碼(為簡單起見而被剝離):import Foundationclass FBManager {    class func fbSessionStateChane(fbSession:FBSession!, fbSessionState:FBSessionState, error:NSError?){        //... handling all session states        FBRequestConnection.startForMeWithCompletionHandler { (conn: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in            println("Logged in user: \n\(result)");            let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())            let loggedInView: UserViewController = storyboard.instantiateViewControllerWithIdentifier("loggedInView") as UserViewController            loggedInView.result = result;            //todo: segue to the next view???        }    }}我正在使用上面的類方法來檢查會話狀態更改,并且工作正常。問:獲得用戶數據后,如何在此自定義類中選擇下一個視圖?編輯:為了清楚起見,我在情節提要上有一個帶有標識符的segue,并且我試圖找到一種從不是視圖控制器的類中執行segue的方法
查看完整描述

3 回答

?
慕標琳琳

TA貢獻1830條經驗 獲得超9個贊

如果情節提要存在于情節提要中,并且在兩個視圖之間都有一個情節標識符,則可以使用以下方式以編程方式調用它:


performSegue(withIdentifier: "mySegueID", sender: nil)

對于舊版本:


performSegueWithIdentifier("mySegueID", sender: nil)

您也可以這樣做:


presentViewController(nextViewController, animated: true, completion: nil)

或者,如果您在導航控制器中:


self.navigationController?.pushViewController(nextViewController, animated: true)


查看完整回答
反對 回復 2019-10-15
?
三國紛爭

TA貢獻1804條經驗 獲得超7個贊

您可以使用NSNotification


在您的自定義類中添加一個post方法:


NSNotificationCenter.defaultCenter().postNotificationName("NotificationIdentifier", object: nil)

在您的ViewController中添加觀察者:


NSNotificationCenter.defaultCenter().addObserver(self, selector: "methodOFReceivedNotication:", name:"NotificationIdentifier", object: nil)

在您的ViewController中添加功能:


func methodOFReceivedNotication(notification: NSNotification){

    self.performSegueWithIdentifier("yourIdentifierInStoryboard", sender: self)

}


查看完整回答
反對 回復 2019-10-15
?
喵喔喔

TA貢獻1735條經驗 獲得超5個贊

如果情節提要存在于情節提要中,并且在兩個視圖之間都有一個情節標識符,則可以使用以下方式以編程方式調用它:


self.performSegueWithIdentifier("yourIdentifierInStoryboard", sender: self)

如果您在導航控制器中


let viewController = YourViewController(nibName: "YourViewController", bundle: nil)        

self.navigationController?.pushViewController(viewController, animated: true)

我將建議您使用導航控制器的第二種方法。


查看完整回答
反對 回復 2019-10-15
  • 3 回答
  • 0 關注
  • 432 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號