Pregunta

I have a button in a viewcontroller which I linked with another ViewController.

On the implementation of the first viewController I created this method:

- (IBAction)SignUpPressed:(id)sender {
    [self performSegueWithIdentifier:@"signup" sender:self];
}

But when I test it on the simulator, I press the button and the app crashes

argc    int 1   1
argv    char ** 0x7fff5fbfece8  0x00007fff5fbfece8


libc++abi.dylib: terminating with uncaught exception of type NSException

Returning this errors. What can I do to fix this?

APPENDIX:

Code around the error (all code is above the error point)

    #import "LoginViewController.h"
    #import "ADVTheme.h"

    @interface LoginViewController ()

    @end

    @implementation LoginViewController



    - (void)viewDidLoad
    {
        [super viewDidLoad];

        id <ADVTheme> theme = [ADVThemeManager sharedTheme];

        [self.view setBackgroundColor:[UIColor colorWithPatternImage:[theme viewBackground]]];



        [self.loginButton setBackgroundImage:[theme colorButtonBackgroundForState:normal] forState:UIControlStateNormal] ;

         [self.loginButton setBackgroundImage:[theme colorButtonBackgroundForState:UIControlStateHighlighted] forState: UIControlStateHighlighted];
    }

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        self.title = @"Login";
    }

    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }

    #pragma mark - Table view data source

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {

        // Return the number of sections.
        return 0;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {

        // Return the number of rows in the section.
        return 0;
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

        // Configure the cell...

        return cell;
    }

All exception Traceback


014-02-01 11:55:05.904 theBeeGame[15793:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<LoginViewController: 0x10982c3b0>) has no segue with identifier 'signup''
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000101f90795 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000101cf3991 objc_exception_throw + 43
    2   UIKit                               0x0000000100a43e05 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
    3   theBeeGame                          0x0000000100005cf1 -[LoginViewController SignUpPressed:] + 97
    4   UIKit                               0x0000000100957096 -[UIApplication sendAction:to:from:forEvent:] + 80
    5   UIKit                               0x0000000100957044 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17
    6   UIKit                               0x0000000100a2b450 -[UIControl _sendActionsForEvents:withEvent:] + 203
    7   UIKit                               0x0000000100a2a9c0 -[UIControl touchesEnded:withEvent:] + 530
    8   UIKit                               0x000000010098bc15 -[UIWindow _sendTouchesForEvent:] + 701
    9   UIKit                               0x000000010098c633 -[UIWindow sendEvent:] + 988
    10  UIKit                               0x0000000100965fa2 -[UIApplication sendEvent:] + 211
    11  UIKit                               0x0000000100953d7f _UIApplicationHandleEventQueue + 9549
    12  CoreFoundation                      0x0000000101f1fec1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    13  CoreFoundation                      0x0000000101f1f792 __CFRunLoopDoSources0 + 242
    14  CoreFoundation                      0x0000000101f3b61f __CFRunLoopRun + 767
    15  CoreFoundation                      0x0000000101f3af33 CFRunLoopRunSpecific + 467
    16  GraphicsServices                    0x000000010293c3a0 GSEventRunModal + 161
    17  UIKit                               0x0000000100956043 UIApplicationMain + 1010
    18  theBeeGame                          0x0000000100002ed3 main + 115
    19  libdyld.dylib                       0x00000001033295fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
¿Fue útil?

Solución

Please set your segue identifier "signup" on stoarybord controller.

Otros consejos

the convention on iOS is to have method starting with lowerCase and camelCase. Make sure that your control is hooked up to the correct IBaction (case-sensitive!). Also make sure your segue identifier matches exactly (case-sensitive).

Lastly, show full exception, stack trace and the code around the location where the exception occurs (for this, set an exception breakpoint).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top