Created
September 7, 2011 14:38
-
-
Save Amosel/1200747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
iOS5 UIViewControllers introduced API changes with the parentViewController. | |
I'm not 100% clear why this needs to be break existing code: | |
calling parentViewController the second time on a UINavigationController returns nil. | |
For instance to insert controllers to a bottom navigationtion stack. | |
So instead simply call presentingViewController to get the bottom UINavigationController. | |
*/ | |
if ([self respondsToSelector:@selector(presentingViewController)]) | |
{ | |
UINavigationController*parent = (UINavigationController*) self.presentingViewController; | |
NSMutableArray* controllers = [[[parent viewControllers] mutableCopy] autorelease]; | |
CPVenueDetailViewController *aRestaurantDetailController = [[CPVenueDetailViewController alloc]initWithNibName:nil | |
bundle:nil]; | |
aRestaurantDetailController.venue = (CPVenue*)annotation; | |
[controllers addObject:aRestaurantDetailController]; | |
[parent setViewControllers:controllers]; | |
[self.parentViewController dismissModalViewControllerAnimated:NO]; | |
[aRestaurantDetailController release]; | |
} | |
else | |
{ | |
UINavigationController *parent = (UINavigationController*) | |
[(UINavigationController*)self.parentViewController parentViewController]; | |
NSMutableArray* controllers = [[[parent viewControllers] mutableCopy] autorelease]; | |
CPVenueDetailViewController *aRestaurantDetailController = [[CPVenueDetailViewController alloc]initWithNibName:nil | |
bundle:nil]; | |
aRestaurantDetailController.venue = (CPVenue*)annotation; | |
[controllers addObject:aRestaurantDetailController]; | |
[parent setViewControllers:controllers]; | |
[self.parentViewController dismissModalViewControllerAnimated:NO]; | |
[aRestaurantDetailController release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment