Skip to content

Instantly share code, notes, and snippets.

#import "MyCustomSegue.h"
@implementation MyCustomSegue
- (void)perform
{
UIView *sourceView = ((UIViewController *)self.sourceViewController).view;
UIView *destinationView = ((UIViewController *)self.destinationViewController).view;
- (void)perform
{
UIView *sourceView = ((UIViewController *)self.sourceViewController).view;
UIView *destinationView = ((UIViewController *)self.destinationViewController).view;
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
destinationView.center = CGPointMake(sourceView.center.x, sourceView.center.y - destinationView.center.y);
[window insertSubview:destinationView aboveSubview:sourceView];
//in MyCustomUnwindSegue.m
// 1. beloveSubview
[window insertSubview:destinationView belowSubview:sourceView];
// instead of aboveSubview
[window insertSubview:destinationView aboveSubview:sourceView];
#import "MyCustomUnwindSegue.h"
@implementation MyCustomUnwindSegue
- (void)perform
{
UIView *sourceView = ((UIViewController *)self.sourceViewController).view;
UIView *destinationView = ((UIViewController *)self.destinationViewController).view;
#import "MyCustomUnwindSegue.h"
@implementation MyCustomUnwindSegue
- (void)perform
{
UIView *sourceView = ((UIViewController *)self.sourceViewController).view;
UIView *destinationView = ((UIViewController *)self.destinationViewController).view;
- (IBAction)returnedFromSegue:(UIStoryboardSegue *)segue {
NSLog(@"Returned from second view");
if ([[segue identifier] isEqualToString:@"UnwindFromSecondView"]) {
self.view.backgroundColor = [UIColor orangeColor];
}
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
{
//how to set identifier for an unwind segue:
//1. in storyboard -> documento outline -> select your unwind segue
//2. then choose attribute inspector and insert the identifier name
if ([@"UnwindFromSecondView" isEqualToString:identifier]) {
return [[MyCustomUnwindSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController];
}else {
#import "MyNavController.h"
#import "MyCustomUnwindSegue.h"
@interface MyNavController ()
@end
@implementation MyNavController
- (void)viewDidLoad {
@implementation ViewController
@synthesize TextField1, TextField2;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.TextField1.placeholder = @"I am TF 1";
self.TextField2.placeholder = @"I am TF 2";
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
// When start to edit the placeholder will disappear
self.TextField1.placeholder = @"";
self.TextField2.placeholder = @"";
}
- (void)textFieldDidEndEditing:(UITextField *)textField {