-
-
Save Hackmodford/8030406 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
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
self.window.backgroundColor = [UIColor whiteColor]; | |
[self.window makeKeyAndVisible]; | |
UITabBarController* tabController = [[UITabBarController alloc] init]; | |
tabController.viewControllers = @[ | |
[[UINavigationController alloc] initWithRootViewController:[[FirstController alloc] init]], | |
[[UINavigationController alloc] initWithRootViewController:[[FirstController alloc] init]] | |
]; | |
self.window.rootViewController = tabController; | |
return YES; | |
} | |
@end |
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
#import <Foundation/Foundation.h> | |
@interface FirstController : UITableViewController | |
{ | |
} | |
@end |
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
#import "FirstController.h" | |
#import "SecondController.h" | |
@implementation FirstController | |
-(id)init | |
{ | |
if( (self = [super init]) ) | |
{ | |
self.tabBarItem.title = @"Foo"; | |
self.tabBarItem.image = [UIImage imageNamed:@"Tab Icon.png"]; | |
} | |
return self; | |
} | |
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section | |
{ | |
return 1; | |
} | |
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath | |
{ | |
UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; | |
cell.textLabel.text = @"Click"; | |
return cell; | |
} | |
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath | |
{ | |
SecondController* controller = [[SecondController alloc] init]; | |
self.tabBarController.tabBar.hidden = YES; | |
[self.navigationController pushViewController:controller animated:YES]; | |
} | |
@end |
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
#import <Foundation/Foundation.h> | |
@interface SecondController : UIViewController | |
{ | |
} | |
@end |
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
#import "SecondController.h" | |
@implementation SecondController | |
-(void)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
self.view.backgroundColor = [UIColor redColor]; | |
self.view.clipsToBounds = YES; | |
/* ENTER VORTEX OF DESPAIR */ | |
// without this, there's no gap, but the view continues under the tool | |
// bar; with it, I get the 49-pixel gap thats making my life miserable | |
self.edgesForExtendedLayout = UIRectEdgeNone; | |
//this resizes the navigation controller to fill the void left by the tab bar. | |
CGRect newFrame = self.navigationController.view.frame; | |
newFrame.size.height = newFrame.size.height + 49; | |
self.navigationController.view.frame = newFrame; | |
/* EXIT VORTEX OF DESPAIR */ | |
self.navigationController.toolbarItems = @[ | |
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:nil action:nil] | |
]; | |
} | |
-(void)viewDidAppear:(BOOL)animated | |
{ | |
[super viewDidAppear:animated]; | |
self.navigationController.toolbarHidden = NO; | |
// will log a height of 411, instead of the desired 460 | |
NSLog(@"frame: %@", NSStringFromCGRect(self.view.frame)); | |
NSLog(@"frame: %@", NSStringFromCGRect(self.navigationController.view.frame)); | |
} | |
-(void)viewWillDisappear:(BOOL)animated { | |
[super viewWillDisappear:animated]; | |
self.tabBarController.tabBar.hidden = NO; | |
self.navigationController.toolbarHidden = YES; | |
//this resizes the navigation controller back to normal. | |
CGRect newFrame = self.navigationController.view.frame; | |
newFrame.size.height = newFrame.size.height - 49; | |
self.navigationController.view.frame = newFrame; | |
//this is optional and resizes the view to fill the void left by the missing toolbar. | |
CGRect newViewFrame = self.view.frame; | |
newViewFrame.size.height = newViewFrame.size.height + 49; | |
self.view.frame = newViewFrame; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment