Last active
December 31, 2015 12:59
-
-
Save moreindirection/7989417 to your computer and use it in GitHub Desktop.
Tab Bar issue in iOS 7
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.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 | |
-(id)init | |
{ | |
if( (self = [super init]) ) | |
{ | |
self.hidesBottomBarWhenPushed = YES; | |
} | |
return self; | |
} | |
-(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; | |
/* EXIT VORTEX OF DESPAIR */ | |
self.navigationController.toolbarItems = @[ | |
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:nil action:nil] | |
]; | |
self.navigationController.toolbarHidden = NO; | |
} | |
-(void)viewDidAppear:(BOOL)animated | |
{ | |
[super viewDidAppear:animated]; | |
// will log a height of 411, instead of the desired 460 | |
NSLog(@"frame: %@", NSStringFromCGRect(self.view.frame)); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment