Skip to content

Commit

Permalink
Fix for some split view drawing issues when using nav groups as detai…
Browse files Browse the repository at this point in the history
…l/master.
  • Loading branch information
sptramer committed Jul 19, 2010
1 parent 6a91004 commit 2df74ce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
35 changes: 26 additions & 9 deletions iphone/Classes/TiSplitViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#import "TiSplitViewController.h"
#import "TiViewProxy.h"
#import "TiUIiPhoneNavigationGroupProxy.h"
#import <MessageUI/MessageUI.h>

@implementation TiSplitViewController
Expand All @@ -27,21 +28,37 @@ -(id)initWithRootController:(TiRootViewController *)rootController
titaniumRoot = [rootController retain];
proxy = split_;

master = [[TiViewController alloc] initWithViewProxy:master_];
detail = [[TiViewController alloc] initWithViewProxy:detail_];

UINavigationController *leftNav = [[UINavigationController alloc] initWithRootViewController:master];
UINavigationController *rightNav = [[UINavigationController alloc] initWithRootViewController:detail];

leftNav.navigationBarHidden = YES;
rightNav.navigationBarHidden = YES;

// In order for the split view to render correctly, we have to enforce the window's orientation modes
// before setting up the view controllers. Very finnicky about when the containing mystery views
// are positioned!
lastOrientation = [[UIDevice currentDevice] orientation];
[self enforceOrientationModesFromWindow:(TiWindowProxy*)split_ rotate:NO];

// Split view throws a hissyfit unless its detail and master are nav groups, apparently!
UINavigationController* leftNav;
UINavigationController* rightNav;

// Quick hack; OK to do this even if we're stashing nav group proxies, because we're just
// using these to resposition (and create the nav controller if necessary)
master = [[TiViewController alloc] initWithViewProxy:master_];
detail = [[TiViewController alloc] initWithViewProxy:detail_];

if ([master_ isKindOfClass:[TiUIiPhoneNavigationGroupProxy class]]) {
leftNav = [[(TiUIiPhoneNavigationGroupProxy*)master_ controller] retain];
}
else {
leftNav = [[UINavigationController alloc] initWithRootViewController:master];
leftNav.navigationBarHidden = YES;
}

if ([detail_ isKindOfClass:[TiUIiPhoneNavigationGroupProxy class]]) {
rightNav = [[(TiUIiPhoneNavigationGroupProxy*)detail_ controller] retain];
}
else {
rightNav = [[UINavigationController alloc] initWithRootViewController:detail];
rightNav.navigationBarHidden = YES;
}

self.viewControllers = [NSArray arrayWithObjects:leftNav, rightNav ,nil];

[leftNav release];
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUIiPhoneNavigationGroupProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
@private
}

-(UINavigationController*)controller;

@end

#endif
5 changes: 5 additions & 0 deletions iphone/Classes/TiUIiPhoneNavigationGroupProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ -(void)close:(NSArray*)args
}
}

-(UINavigationController*)controller
{
return [[self view] controller];
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if ([self viewAttached])
Expand Down

0 comments on commit 2df74ce

Please sign in to comment.