reybis
reybis

Reputation: 89

call segue right when another segue ends

why it's not possible to call a segue right when another segue ends?. I guess must be my code is wrong or is impossible to call?

- (IBAction)optionTapped
{
    if (greeting)
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alerta!" message:@"something.." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
            [self performSegueWithIdentifier:@"firstSegue" sender:itemToSent];
            greeting = NO;
        }
    else
        {
            [self performSegueWithIdentifier:@"anotherSegue" sender:nil];
        }
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"anotherSegue"]) {
        UIViewController *viewController = segue.destinationViewController;
        OptionsViewController *controller = (OptionsViewController *)viewController;
        controller.delegate = self;
    } else if ([segue.identifier isEqualToString:@"firstSegue"]) {
        UINavigationController *navigationController = segue.destinationViewController;
        CCGetViewController *controller = (CCGetViewController *)navigationController.topViewController;
        controller.delegate = self;
        controller.itemToSent = sender;
    }

- (void)firstSegueViewController:(CCGetViewController *)controller didFinishAddItem:(InfoListItems *)item
{
    itemToSent = item;
    [self dismissViewControllerAnimated:YES completion:nil];
    if (scanTap) {
        [self scanTapped];
    } else if(infoTap){
        [self optionTapped];
    }
}

one more thing: the "firstSegue" is embed it on NavigationController and "anotherSegue" is just a view controller.

Upvotes: 0

Views: 251

Answers (1)

Feel Physics
Feel Physics

Reputation: 2783

I tried to move segue continually, but I failed, too.

So I tried to set interval between first segue and second segue for one second.

ss

This works well ! When you push button in red window, green window appears, and after it, blue window appears automatically.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self performSelector:@selector(segue) withObject:nil afterDelay:1.0];
}

- (void)segue
{
    [self performSegueWithIdentifier:@"toBlue" sender:self];
}

You can download sample project and just run it:

https://github.com/weed/p120812_DoubleSegue

Upvotes: 1

Related Questions