Reputation: 609
I am making an app where I have multiple different screens that does different things. I have it all working with pop/push in an UINavigationController.
The layout is then something like this. The gray is each "uiviewcontroller", the rectangle is part of the background-picture and the RGB is the 'content' in each uiviewcontroller.
I want to make it seem that all of the different screens are in the same "space". Like the next image.
I have been playing with custom segues and it "kind of" works. It removes the "push"/"pop" visual and it animates smoothly, it works great if the background is of one color. But that's not the case, in fact my background will have an animation where it spins ever so slowly.
So how should I go about this?
Things I've tried or thought about
I've been sitting on this problem for a good 2 days now but I am not sure how to best go about it.
EDIT: I used the UIPageViewController solution below and this is the resulting "app".
Upvotes: 1
Views: 632
Reputation: 4884
Have you tried using UIPageViewController? If you want change the UIViewController with swipe gesture, it will be the answer. It' available from iOS 6.
RootVC.h
@interface RootVC : UIPageViewController
@end
RootVC.m
@interface RootVC () <UIPageViewControllerDelegate, UIPageViewControllerDataSource>
{
NSArray *_viewControllers;
}
@end
@implementation RootVC
- (void)viewDidLoad
{
[super viewDidLoad];
LeftViewController *lv = [[LeftViewController alloc] init];
CenterViewController *cv = [[CenterViewController alloc] init];
RightViewController *rv = [[RightViewController alloc] init];
_viewControllers = @[lv, cv, rv];
[self setViewControllers:@[cv] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished) {
}];
[self setDelegate:self];
[self setDataSource:self];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
NSInteger index = [_viewControllers indexOfObject:viewController];
if(index > 0)
{
index--;
return [_viewControllers objectAtIndex:index];
}
else
{
return nil;
}
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
NSInteger index = [_viewControllers indexOfObject:viewController];
if(index < 2)
{
index++;
return [_viewControllers objectAtIndex:index];
}
else
{
return nil;
}
}
Upvotes: 1
Reputation: 411
You don't need three UIViewControllers.
Upvotes: 0
Reputation: 199
Have you tried putting your view controllers in container views? Maybe it will fit your needs.
https://developer.apple.com/videos/wwdc/2011/?id=102
Upvotes: 0