Dailycode.info

Short solution for short problems

iOS: cannot find manuel segue

I had an application with a dashboard with dynamic number of button. Based on the button description, a segue would be triggered. This works fine. But at a moment, a certain push segue was not found. So I triple checked the name, debugged and debugged, but could not find the problem. Also the application did no respond to other segues anymore. 

The problem was that I copy a view controller on the story board, then changed it and created a new manuel segue to it. Were the view controller of which I copied the new VC from was also referring. This was causing the problem. I guess there is somewhere still a reference because it was a copy. 

Now I solved it by simply adding a new view controller to the story board, then copy paste all controls to this and changed the view controller class. Deleted the first copy, then set the manual segue to the new view controller and everything worked. I had to hook up all the outlets and events off course. 


iOS : Custom Flip Segue (portrait and landscape layout) xcode 4

Using segues is really easy. Get use to the visual programming! If you draw segues its still a shame that you cannot visual change the animation on the segues. But then the implementation of a custom animation is not so hard.

First create a new Objective C class and give it a usefull name. For example: FlipSegue. 

This class should inherit from the UIStoryboardSegue.

#import <UIKit/UIKit.h>

 

@interface FlipSegue : UIStoryboardSegue

 

@end

Then in the implementation file we override the perform method. Below you can see that I do a check if the orientation is landscape or portrait, because then you will always flip from left to right. If not, when you change orientation, it will flip from top to bottom. Here is the full code for the custom segue implementation.

#import "FlipSegue.h"

 

@implementation FlipSegue

- (void)perform

{

    UIInterfaceOrientation orientation = [self.sourceViewControllerinterfaceOrientation];

    if (UIInterfaceOrientationIsPortrait(orientation))

    {

        UIViewController *src = (UIViewController *) self.sourceViewController;

        UIViewController *dst = (UIViewController *) self.destinationViewController;

        [UIViewtransitionWithView:src.navigationController.view duration:0.8 options:UIViewAnimationOptionTransitionFlipFromLeft

                    animations:^{

                        [src.navigationController pushViewController:dst animated:NO];

                    }

                    completion:NULL];

    }

    else

    {

        UIViewController *src = (UIViewController *) self.sourceViewController;

        UIViewController *dst = (UIViewController *) self.destinationViewController;

        [UIViewtransitionWithView:src.navigationController.view duration:0.8 options:UIViewAnimationOptionTransitionFlipFromBottom

                        animations:^{

                            [src.navigationController pushViewController:dst animated:NO];

                        }

                        completion:NULL];

    }

}

 

@end

Now the last thing we need to do is tell the Segue that it has to inherit from this class: