1

I currently have three view controllers going on in my iPhone application at the same time.
I use a slidingView.

Here is my image:

enter image description here

When I tap on a table view cell, I want to open a new view controller like this:

enter image description here

(the egg is representing a new view controller.

But as you can see my orange view controller is in front.

How do I change this?

The code I use to open the egg-viewcontroller:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIViewController *boxView = [self.storyboard instantiateViewControllerWithIdentifier:@"BoxView"];
    boxView.modalPresentationStyle = UIModalPresentationFormSheet;
    boxView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    boxView.view.frame=CGRectMake(-50, 5, 300, 470);
    [self.view addSubview:boxView.view];
    //[self.view bringSubviewToFront:boxView];

}
Neeku
  • 3,646
  • 8
  • 33
  • 43
rostgaard
  • 325
  • 1
  • 6
  • 19

1 Answers1

0

It should be quite easy, you need your parent view controller (i.e. the orange controller ) to add the subview of your new view controller. You could normally do that by [self.parentViewController addSubview:boxView.view] . But since you are using ECSlidingViewController , you could do it like this: [self.slidingViewController.topViewController.view addSubview:boxView.view].

Of course then you will need to adjust your new ViewController's frame accordingly.

nluo
  • 2,147
  • 1
  • 14
  • 11
  • No problem Mark! To be able to close, what comes on my head now is you need to add a button/tap gesture to the view , and when you click/touch it, you gonna trigger [self.boxView.view removeFromSuperView]. I will suggest you declare your new view controller (i.e. boxView Controller) as a property , e.g. @property (strong,nonatomic)UIViewController *boxView, because u will want to access it like self.boxView – nluo Jan 20 '13 at 23:56