接收方没有识别符错误消息的提示 [英] Receiver has no segue with identifier error message

查看:47
本文介绍了接收方没有识别符错误消息的提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xcode 7 beta和swift 2.0.我正在学习教程(youtube.com/watch?v=PKOswUE731c).

I am using xcode 7 beta and swift 2.0. I am following a tutorial (youtube.com/watch?v=PKOswUE731c).

简而言之,我有一个故事板,具有3个视图;受保护的vc,登录vc和RegisterViewController.我设置了2个segg

In short i have a storyboard with 3 views; a protected vc, a login vc and RegisterViewController. I have set 2 segues

seudo模态,带有protected_vc<->用loginView标识的login_vc

segue modal with protected_vc <-> login_vc identified with loginView

login_vc中按钮上的搜索模式<->用registerView标识的RegisterViewController

segue modal on a button in login_vc <-> RegisterViewController identified with registerView

我在登录vc上使用注册按钮时遇到问题.如果我单击注册按钮,它将使应用程序崩溃,并显示消息'Receiver(< registerLogin.RegisterViewController:0x7f97235f6140>)'没有标识为'loginView'

I encountered a problem when with a register button on my login vc. If i click the register button it crashes the app and i get the message 'Receiver (<registerLogin.RegisterViewController: 0x7f97235f6140>) has no segue with identifier 'loginView''

现在我注意到在教程中选择一个segue会提供另一个下拉菜单,在我的情况下,我仅看到push-modal -popover-replace and custom.这可能是原因吗?

Now i notice in the tutorial selecting a segue gives another dropdown, in my case i only see push - modal -popover - replace and custom. Could this be the cause??

或者这部分ViewController

Or this part ViewController

 override func viewDidAppear(animated: Bool) {
        self.performSegueWithIdentifier("loginView", sender: self);
    }

RegisterViewController的完整代码是

Complete code for RegisterViewController is

import UIKit

class RegisterViewController: ViewController {


    @IBOutlet weak var userEmailTextField: UITextField!

    @IBOutlet weak var userPasswordTextField: UITextField!
    @IBOutlet weak var repeatPasswordTextField: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    @IBAction func registerButtonTapped(sender: AnyObject) {

        let userEmail = userEmailTextField.text
        let userPassword = userPasswordTextField.text
        let repeatPassword = repeatPasswordTextField.text

        //No empty fields
        if((userEmail!.isEmpty || userPassword!.isEmpty || repeatPassword!.isEmpty)){
            //Display alert message
            displayMyAlertMessage("All fields required")
            return
        }
        //Check if passwords match
        if(userPassword != repeatPassword){
            //Display alert message 
            displayMyAlertMessage("Passwords mistakes")
            return
        }

        //Store data
        NSUserDefaults.standardUserDefaults().setObject(userEmail, forKey: "userEmail")
        NSUserDefaults.standardUserDefaults().setObject(userPassword, forKey: "userPassword")

        NSUserDefaults.standardUserDefaults().synchronize()

        //Display alert message with confirmation
        let myAlert = UIAlertController(title: "Alert", message: "Registration successful", preferredStyle: UIAlertControllerStyle.Alert)
        let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default) { action in
            self.dismissViewControllerAnimated(true, completion: nil)
        }


    }


    func displayMyAlertMessage(userMessage:String){
        let myAlert = UIAlertController(title: "Alert", message: userMessage, preferredStyle: UIAlertControllerStyle.Alert)

        let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil)

        myAlert.addAction(okAction)

        self.presentViewController(myAlert, animated: true, completion: nil)
    }

}

和完整的错误消息(手动换行的第一行):

and the complete error message (manually wrapped first line):

2015-10-11 07:17:57.378 registerLogin[667:10462] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'Receiver (<registerLogin.RegisterViewController: 0x7fb7f978d4c0>) 
has no segue with identifier 'loginView''
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000102d249b5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104923deb objc_exception_throw + 48
    2   UIKit                               0x00000001036caba3 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
    3   registerLogin                       0x0000000102b4260f _TFC13registerLogin14ViewController13viewDidAppearfS0_FSbT_ + 127
    4   registerLogin                       0x0000000102b42661 _TToFC13registerLogin14ViewController13viewDidAppearfS0_FSbT_ + 49
    5   UIKit                               0x00000001036cd82e -[UIViewController _setViewAppearState:isAnimating:] + 830
    6   UIKit                               0x00000001036ce1b0 -[UIViewController _endAppearanceTransition:] + 262
    7   UIKit                               0x000000010369950e -[UIPresentationController transitionDidFinish:] + 827
    8   UIKit                               0x0000000103857c17 -[_UICurrentContextPresentationController transitionDidFinish:] + 42
    9   UIKit                               0x000000010369c97e __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 183
    10  UIKit                               0x0000000103eb105c -[_UIViewControllerTransitionContext completeTransition:] + 101
    11  UIKit                               0x00000001036963fb -[UITransitionView notifyDidCompleteTransition:] + 252
    12  UIKit                               0x000000010369610c -[UITransitionView _didCompleteTransition:] + 1344
    13  UIKit                               0x0000000103698878 -[UITransitionView _transitionDidStop:finished:] + 104
    14  UIKit                               0x00000001035c3a63 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
    15  UIKit                               0x00000001035c3e12 -[UIViewAnimationState animationDidStop:finished:] + 80
    16  QuartzCore                          0x000000010799bd70 _ZN2CA5Layer23run_animation_callbacksEPv + 308
    17  libdispatch.dylib                   0x000000010540d4bb _dispatch_client_callout + 8
    18  libdispatch.dylib                   0x00000001053f53ff _dispatch_main_queue_callback_4CF + 1738
    19  CoreFoundation                      0x0000000102c84e69 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    20  CoreFoundation                      0x0000000102c463b9 __CFRunLoopRun + 2073
    21  CoreFoundation                      0x0000000102c45918 CFRunLoopRunSpecific + 488
    22  GraphicsServices                    0x000000010722dad2 GSEventRunModal + 161
    23  UIKit                               0x000000010354199e UIApplicationMain + 171
    24  registerLogin                       0x0000000102b4323d main + 109
    25  libdyld.dylib                       0x000000010544292d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我已经设置好了

并通过注册按钮

在项目中对术语loginView的查找仅给出2个搜索结果(见图像),所以我不知道RegisterViewController认为需要" loginView的地方

A find in project on the term loginView only gives 2 search results see image, so i don't get where RegisterViewController "thinks" it needs loginView

推荐答案

您的类 RegisterViewController ViewController 的子类,但可能应该是的子类UIViewController .可能您的 ViewController 类是创建新项目时已经创建的主视图控制器.

Your class RegisterViewController is a subclass of ViewController, but likely should be a subclass of UIViewController. Probably your ViewController class is the main view controller already created when creating a new project.

RegisterViewController ViewController 的子类时,它还将继承 viewDidAppear 方法.因此,当它出现时,它用 loginView 调用 performSegue ... ,但是现在有了 RegisterViewController 的实例,就没有 loginView segue.因此是例外.

When RegisterViewController is a subclass of ViewController, it also inherits the viewDidAppear method. Therefore when it appears it calls performSegue... with loginView, but now with the instance of RegisterViewController there is no loginView segue. Hence the exception.

下面的原始答案,这可能是类型的异常没有标识符为'... name ...'的异常的原因.

Original answer below, which is the likely reason for an exception of the kind has no segue with identifier '...name...':

可能您的segue标识符未设置或拼写错误.

Likely your segue identifier is not set or misspelled.

  1. 单击segue
  2. 确保右侧的实用工具"面板可见
  3. 确保属性检查器可见
  4. 在"Storyboard Segue"下检查"Identifier"的值(在屏幕快照中为"infoSegue")

这篇关于接收方没有识别符错误消息的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆