私のHomeViewControllerには、セルがクリックされたときにアクティブなものと、join list
というタイトルのバーボタンアイテムがクリックされたときのものがあります。バーボタンの項目をクリックすると、ユーザーがログインしているかどうかをチェックしたいと思います。ユーザーがログインしていない場合は、LoginViewControllerインターフェースを表示し、ログインしている場合はjoinViewControllerのインターフェースを表示します。私はjoinViewControllerに参加intemからCtrlキーを保持することにより、ストーリーボードから参加セグエを作成し、これはビューすぐに表示を消す
class LoginViewController: UIViewController {
@IBAction func dismissView(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)
に却下する
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "detail" {
var detailScene=segue.destinationViewController as! DetailViewController
if let indexPath=self.table.indexPathForSelectedRow{
let selectedPerson=listPerson[indexPath.row]
detailScene.person=selectedPerson
}}
else
if segue.identifier == "join"{
if !userLoggedIn{
let vc : AnyObject! = self.storyboard!.instantiateViewControllerWithIdentifier("LoginViewController")
self.presentViewController(vc as! UIViewController, animated: true, completion: nil)
}
}
}
すべてが正常に動作しているが、LoginViewControllerに私が追加され、IBAction私のコードです
ボタンをクリックすると、homeViewControlledではなくjoinViewControllerがロードされます。私は何をきれいにしたのですか?また、解除ボタンをどうやって修正できますか?
あなたの 'HomeViewController'で' shouldPerformSegueWithIdentifier'をオーバーライドし、そこにログインロジックを移動することができます。ログインしていなければ 'false'を返し、そうでなければ' true'を返します。お役に立てれば。 – riik