ios7 Tabbar covers tableview - ios7

I have a new ios7 tabbar app. the app delegate looks something like this.
SomeViewController *someView = [[SomeViewController alloc] initWithNibName:#"SomeViewController" bundle:nil];
UINavigationController *someNav = [[UINavigationController alloc] initWithRootViewController:someView];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:someNav, nil];
self.tabBarController.delegate = self;
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
SomeViewController is a simple view with a full size UITableView embedded. Now when the application runs the tableview will not scroll above the tab bar.
I have tried many many suggestions, such as
self.edgesForExtendedLayout = UIRectEdgeNone;
self.tabBarController.tabBar.translucent = NO;
but nothing seems to work. In IB I turn on the guides and set the height of the table view to be above the tab bar but that doesnt work either.
Rather stuck on something I am sure is very simple.
TIA

Does:
self.tabBarController.edgesForExtendedLayout = UIRectEdgeNone
help?

Related

presentViewController shows black sceen while UIModalTransitionStyleFlipHorizontal objective c

I'm facing issue with the UIModalTransitionStyleFlipHorizontal, Which gives black screen at background while transition and shows the actual screen.
After first time it shows the last view which added as rootview.
What actually I need to achieve is I don want to show the black and previous screen. It should show an empty screen background as like the below image.
The code I used to achieve the transition is
- (void)popViewController {
UIViewController* rootController = [[UIStoryboard storyboardWithName:#"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:#"MainViewController"];
rootController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
UINavigationController *navigation = [[UINavigationController alloc]initWithRootViewController:rootController];
[self.window.rootViewController presentViewController:navigation animated:YES completion:nil];
[self.window makeKeyAndVisible];
}
I'm using storyboard with dynamic rootview.Anybody help me to fix it out.
Thanks
Remove subview
Add this code on your method popViewController
AppDelegate *appDelegate =(AppDelegate *)[[UIApplication sharedApplication]delegate];
NSArray *subViewArray = [appDelegate.window subviews];
for (id obj in subViewArray)
{
[obj removeFromSuperview];
}
I solved the issue by add window subview with background.
UIImageView* background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height)];
background.image = [UIImage imageNamed:#"TermsBg"];
[self.window addSubview:background];

Modifying UINavigation controller programatically in Xcode5

I have a programmatically generated UINavigationController applied to each of my ViewControllers but this UINavigationController is blank. I need to add some text, an image (if possible) and two buttons.
I have managed to do something similar with a very basic app that only has one ViewController and UINavigationController created in the normal manner but do not know what to do in regards to a programmatically generated one.
I am using storyboards in XCode5/iOS7.
Here is the code that generates the UINavigationController and launches the first ViewController:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle: nil];
MainViewController* mainVC = [mainStoryboard instantiateInitialViewController];
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:mainVC];
[self.window setRootViewController:navVC];
[_window makeKeyAndVisible];
return YES;
}
I have tried things that I thought would be obvious like:
navVC.navigationBar.backgroundColor = [UIColor redColor];
To change the colour or:
[navVC setTitle:#"Test title"];
But nothing changes, the only way I could get the title to change was to change the title of mainVC
[mainVC setTitle:#"Test title"];
Changing the title in the MainViewController.m file itself does nothing.
So how do I modify the UINavigationController (navVC)?
Thanks,
You should be able to set an image to your navigation bar in this way:
UINavigationBar *navBar = navVC.navigationBar;
UIImage *image = [UIImage imageNamed:#"YourNavBarImg.png"];
[navBar setBackgroundImage:image];
and this to change the nav bar tint color:
[navVC.navigationBar setTranslucent:NO];
[navVC.navigationBar setBarTintColor:[UIColor redColor]];
about buttons (UIBarButtonItem) into nav bar:
// where "self" is your current viewcontroller
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:button1,button2, nil];

exit from TabBarController to ViewController

I have 2 viewcontrollers in a TabBarController, in 2nd ViewController I have a button which on click should take me to ThanksViewController with out Tabs anymore!!
Please check my code below:
//AppDelegate.m
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:_viewController];
self.window.rootViewController = nav;
//ViewController.m
tab=[[UITabBarController alloc]init];
tab.delegate=self;
oneViewController=[[OneViewController alloc]init];
UINavigationController *oneNav=[[UINavigationController alloc]initWithRootViewController:oneViewController];
oneNav.title=#"One";
twoViewController=[[TwoViewController alloc]init];
UINavigationController *twoNav=[[UINavigationController alloc]initWithRootViewController:twoViewController];
twoNav.title=#"Two";
views=[[NSMutableArray alloc]initWithObjects:oneNav, twoNav, nil];
tab.viewControllers=views;
[tab.view setFrame:CGRectMake(0, 0, 1024, 748)];
[self.view addSubview:tab.view];
In my TwoViewController (tab 2) I've a Button 'OK' which on click should take me to ThanksViewController, for that I've written the following code:
//TwoViewController.m
-(void)OK
{
ThanksViewController *thanksViewController=[[ThanksViewController alloc]init];
[self.navigationController pushViewController:thanksViewController animated:YES];
}
My problem is I want to exit from TabBarController and move on to the ThanksViewController(without TabBarController at the bottom) but in this case I'm getting the ThanksViewController in the TabBarController itself in place of the TwoViewController.
Can someone please suggest me in this case, thanks in advance.
After push ThanksViewController do you want to be possible to go back and present TabBarController again?
If so, use modal, like this:
ThanksViewController *view = [[ThanksViewController alloc] init];
UINavigationController *navThanks = [[UINavigationController alloc] initWithRootViewController:view];
[navThanks setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:navThanks animated:YES];
[self.view setHidden:YES];

UINavigationBar is under StatusBar

I'm developing a tiny app. And I'm having a problem I can't solve. I'm pushing a viewController to a navigationController and this screenshot is showing what's happening.
This is the code I'm using:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.navController = [[UINavigationController alloc] init] ;
[self.window setRootViewController:navController];
[self.window makeKeyAndVisible];
TestViewController *testViewController =[[TestViewController alloc] init];
[navController pushViewController:testViewController animated:YES];
It's driving me crazy, I been gogling for an hour without success, any idea how to fix this?
Update
Is something related with the statusbar. If I change in the info.plist file the "Status Bar is initially hidden" to "NO", then the app works fine but the status bar is shown in the launch screen. Any Idea?
Try initializing your nav controller differently
TestViewController *testViewController =[[TestViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:testViewController];
[self.window setRootViewController:self.navController];
[self.window makeKeyAndVisible];
And for sake of all saints use capital letters for class names.
What I finally did is positioning the UINavigationBar manually. I hope it helps someone else!

Buttons on top of UIPopoverController

I want to add two Buttons on top of UIPopoverController like it is shown in following screenshots:
HTML Edit
Thanks for helping me!
Add your view controller to a UINavigationController, then add the Navigation Controller to the UIPopoverController. Then in your UIViewController's viewDidLoad method, put this code in:
UIBarButtonItem *okButton = [[UIBarButtonItem alloc] initWithTitle:#"Ok" style:UIBarButtonItemStyleBordered target:self action:#selector(okayButtonPressed)];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:#"Cancel" style:UIBarButtonItemStyleBordered target:self action:#selector(cancelButtonPressed)];
self.navigationItem.title = #"My Title";
[self.navigationItem setLeftBarButtonItem:cancelButton animated:NO];
[self.navigationItem setRightBarButtonItem:okButton animated:NO];
[cancelButton release];
[okButton release];
You need to initialize your popover with a UINavigationController directly. Then set the root view to your custom view controller.
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:yourViewController];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
Use a UINavigationController as the pop-over. Then, access the .navigationBar property of the navigation controller, get the .topItem, and set its .leftBarButtonItem and .rightBarButtonItem.
I wouldnt use a navigationcontroller like the previous posters suggested, apple recommends not using navigationcontrollers on ipad (with good reason) it doesnt behave as youd expect when pushing VC into the stack when used in popovers, now you dont really want to use the "navigation" aspect of it, but i wouldnt use navigationcontroller just because uw ant the bar....Use a UIToolBar instead, and set its buttons to whatever you want...no need to use a navigation controller here...
When I do this my navBar doesn't seem to fit properly inside of the UIPopoverController, as shown in the below:
http://www.flickr.com/photos/coleorton/4752223066/
Here's what I'm doing:
// alloc the Direct Reports view controller.
ToolsViewController *toolsViewController = [[[ToolsViewController alloc] init] autorelease];
UINavigationController *toolsNavController = [[[UINavigationController alloc] initWithRootViewController:toolsViewController] autorelease];
toolsNavController.title = #"Tools";
toolsNavController.view.frame = CGRectMake(0.0, -10.0, 320.0, POPOVER_HEIGHT);
if(![self.toolsPopoverController isPopoverVisible]){
// show popover
self.toolsPopoverController = [[[UIPopoverController alloc] initWithContentViewController:toolsNavController] autorelease];
self.toolsPopoverController.delegate = self;
self.toolsPopoverController.popoverContentSize = CGSizeMake(320.0, POPOVER_HEIGHT);
[self.toolsPopoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
} else {
// close popover
[self.toolsPopoverController dismissPopoverAnimated:YES];
}
This worked!
//Determine how to present this view based on device
if ([UIDevice currentDevice ].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
BNRAssetTypeViewController *contentViewController = [[BNRAssetTypeViewController alloc] init];
UINavigationController *popOverNavigation = [[UINavigationController alloc] initWithRootViewController:contentViewController];
self.assetPickerPopover = [[UIPopoverController alloc] initWithContentViewController:popOverNavigation];
[self.assetPickerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
then in the init function of contentViewController add this
//add a barbutton item which will help in adding new type
UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(addNew:)];
//set bar item to right side of navbarite
self.navigationItem.rightBarButtonItem =bbi ;