I have two table views set out. One shows a list of items, say recipe names. The other shows recipe names with descriptions and images. The one with the more detailed view is part of a navigation controller so tapping one of those items pushes another view on top of the stack.
The problem is I have the list of just the recipe names that when tapped I want to push that recipe detail on to the navigation controller stack. These two views are not in the same view hierarchy so I can't just push it in the normal manner.
I've tried passing the content for the view to be pushed onto the stack into a method on the main list, but that didn't do anything.
So, is there a way to get to a navigation controller in another set of views so I can push a view onto it?
If it helps you, here is a workaround I used to get rid of some push issues from subviews. I use a modal segue, with push animation.
You can call them like: [myAnimations modalRight:self destvc:yourDestViewController]. To segue back, from yourDestViewController: [myAnimations modalLeft:self];
myAnimations.h
#import <Foundation/Foundation.h>
@interface myAnimations : NSObject
@end
myAnimations.m
#import "myAnimations.h"
#import <QuartzCore/QuartzCore.h>
@implementation myAnimations
+(void) modalRight:(UIViewController*)vc destvc:(UIViewController*)viewCtrl{
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;// kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;
[vc.view.window.layer addAnimation:transition forKey:nil];
[vc presentModalViewController:viewCtrl animated:NO];
}
+(void) modalLeft:(UIViewController*)vc{
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[vc.view.window.layer addAnimation:transition forKey:nil];
[vc dismissModalViewControllerAnimated:NO];
}
@end
UPDATE: now with IOS 7 and it's nice push animation, the method above will make it look strange. If you want to present modally a viewcotroller that needs to push something (let's call it pusherVC), embed pusherVC in a navigation controller, and present modal the pusher's navigation controller. Then, @ pusherVC you can do self.nafigationcontroller present...