Question

I am trying to load a new UIViewController using a UIButton press method.

this is what the code looks like

- (void) getprojectButtonSelected {

    [self dismissViewControllerAnimated:NO completion:nil];

    currentProjectListViewController = [[CurrentProjectListViewController alloc] initWithNibName:@"CurrentProjectListViewController" bundle:nil];

    UIWindow* keyWindow= [[UIApplication sharedApplication] keyWindow];
    [keyWindow addSubview: currentProjectListViewController.view];

    [self presentViewController:currentProjectListViewController animated:NO completion:nil];
}

I have added currentProjectListViewController in my .h file and am calling it here.. this is the line that fails also...

there is no error code only EXC_BAD_ACCESS

any help would be greatly appreciate.

Was it helpful?

Solution

I think you should take out the [self dismissViewControllerAnimated:NO completion:nil];. There is no reason that should be there. You are supposed to use dismissViewController when you are trying to exit a modal segue. You did not have a current segue so it crashed. Glad it works now!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top