0

Imagine a custom segue ...

-(void)perform
    {
    UIView *sv = ((UIViewController *)self.sourceViewController).view;
    UIView *dv = ((UIViewController *)self.destinationViewController).view;

    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    [window insertSubview:dv aboveSubview:sv];

    [dv coverFromRight:0 then:^
        {
        [self.sourceViewController
         presentViewController:self.destinationViewController
         animated:NO completion:nil];
        }];
    }

Which in fact, only PARTIALLY (!) covers the "underneath, previous" scene,

and in fact DOES NOT call "presentViewController", so, the "underneath, previous" scene in fact keeps operating normally.

-(void)perform
    {
    UIView *sv = ((UIViewController *)self.sourceViewController).view;
    UIView *dv = ((UIViewController *)self.destinationViewController).view;

    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    [window insertSubview:dv aboveSubview:sv];

    [dv coverButOnlyHalfWay:0 then:^
        {
        }];
    }

Essentially, is this possible?

In fact, I've found from experiment the above works (!!). BUT when you come to the custom unwind segue, it does not work: everything crashes. (Perhaps as you'd expect.)

What's the situation? is there a way to make a custom segue, which, covers only say half the "original, underneath" scene and leaves that scene running?

(I appreciate you can just implement this using a container view, but it's not as clean as a whole segue scene.)

Fattie
  • 30,632
  • 54
  • 336
  • 607

1 Answers1

0

Why use a segue? You can just add your view as a subview and position it correct using CGRectMake, this would be much easier.

// Size Your View with X, Y coordinates

[viewController.view setFrame:CGRectMake(0, 0, 320, 192)];
[self.view addSubview:viewController.view];

[viewController didMoveToParentViewController:self];
[self addChildViewController:viewController];
Justin Holman
  • 852
  • 5
  • 7
  • Hi Justin! For sure as I mention at the end there, you could use a container view .. http://stackoverflow.com/a/23403979/294884 (or indeed just roll in a view, as you say). But life is much, much easier, for your logic, data handling, and so on, when you have a whole new VC. (After all, whenever you pop on a whole new scene .. you could just use a UIView!) So yeah I wonder if you can have a "partial screen" segue like that... – Fattie Aug 25 '14 at 17:38
  • I am not talking about a container view, I am saying just add the view to your current view. You can still use a view controller to contain your logic (I have used this approach to create tabs in an app) The segue only helps in move from one scene to another. – Justin Holman Aug 25 '14 at 18:39
  • Hi Justin. Yes, I've sure done that a few times! Note that, any time you use a segue - you could just do that!! life is much easier using scenes and segues (much much easier to compartmentalise and so on), so I'm wondering if it's possible. Note that using a container view, is, the totally natural way to do what you say these days, I think http://stackoverflow.com/a/23403979/294884 – Fattie Aug 25 '14 at 18:57