PresentViewController with Tabbar and Navigationbar iOS - objective-c

I am presenting a view controller class using custom navigation bar as follow:
CreateShiftRosterEventViewController *objDetailView = [[CreateShiftRosterEventViewController alloc] initWithNibName:#"CreateShiftRosterEventViewController" bundle:nil];
CustomNavigationViewController *navcont = [[CustomNavigationViewController alloc] initWithRootViewController:objDetailView];
// Set the user default to 1 to support landscape orientation also for next view
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:#"orientationView"];
[self presentViewController:navcont animated:YES completion:nil];
[objDetailView release];objDetailView = nil;
[navcont release];navcont=nil;
but it hides tab bar at CreateShiftRosterEventViewController class.
Can anyone please help me, what is wrong?

You have created navigationcontroller but you cann't add on view. This is the reason to hide.

You might have added the tab bar, but its not visible because of its autoresize setting. It must be aligned towards bottom of the screen.
You can find the screen shot attached below.

Related

Why is the top of a view controller presented in a UIPopoverController cut off?

My app presents a view controller inside a UIPopoverController when the user presses a button. On iOS7 this works fine, but on the iOS8 beta the top of the view controller is underneath the popover's navigation bar. You can see the difference in the screenshots below.
I've made a really simple app that shows the problem. There's one button connected to the method shown below. contents is a very simple view controller with a yellow background and two labels in it. thePopoverController is a UIPopoverController.
- (IBAction)go:(id)sender {
self.contents = [[ContentsViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:self.contents];
self.thePopoverController = [[UIPopoverController alloc] initWithContentViewController:navController];
[self.thePopoverController presentPopoverFromRect:self.view.frame inView:self.view permittedArrowDirections:0 animated:TRUE];
}
Does anyone know why this happens on iOS8? Is there a way of getting it to work on iOS7 and 8, without having to hard-coded an offset? Any help much appreciated!
Cheers
I had this issue and removing UIRectEdgeTop from my view controller's edgesForExtendedLayout mask fixed it for me. So after setting self.contents, do this:
self.contents.edgesForExtendedLayout = UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight;

presentViewController over TabBarController causes "attempt to present *VC on TabBarVC whose view is not in the window hierarchy"

My root view controller is a Tab Bar Controller loaded in the delegate. Each of the tabs is a table view controller. When the application is first loaded I want a login screen to popup via presentViewController, which I have in my viewDidLoad method of the Tab Bar Controller. It results in the window hierarchy error that I have read about - though none of the solutions have worked for me. I tried instead presenting the modal view in the viewDidLoad method of the first tab but this resulted in the same error.
In my tab bar view controller in viewDidLoad, my code is:
CLLoginViewController *loginVC = [[CLLoginViewController alloc] init];
loginVC.delegate = self;
[self.view addSubview:loginVC.view];
[self presentViewController:loginVC animated:NO completion:nil];
Your question is quite vague but what i have understood, You want to present a login screen before the tabController is loaded.
So a better way would be, In your AppDelegate when setting rootViewController of window, do something like this
if([[NSUserDefaults standardUserDefaults] boolForKey:#"showTabBar"]){
self.window.rootViewController = tabBarControllerObject; //TabBarView is loaded
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"showTabBar"];
}
else{
self.window.rootViewController = tabBarControllerObject; //Login Screen is loaded for first time.
}
Hope this helps

What is best approach to add back button for first view controller in navigation controller?

I'm beginner iOS developer, so don't know how to solve my problem correctly. I have one navigation controller and want to make modal transition to another navigation controller that will have back button on it's first view controller.
In my first navigation controller I made this:
InfoViewController *destinatinViewController = [[InfoViewController alloc] initWithNibName:#"InfoViewController" bundle:nil];
[self presentViewController:destinatinViewController animated:YES completion:nil];
InfoViewController is UINavigationViewController.
Then I made this in InfoViewController (second navigation controller):
InfoRootViewController *rootViewController = [[InfoRootViewController alloc] initWithNibName:#"InfoRootViewController" bundle:nil];
[self pushViewController:rootViewController animated:NO];
For now I know how to add button to go back, but it has not styling (certainly arrow). As I understand because it is only one view in stack of second navigation controller.
So, I need your help to add styled back button for first view controller of navigation controller, because I don't want to make own styling (I'm lazy).
Thanks, for any advance!
PS: I made modal transition because, it has animations like from bottom or top. I tried to use custom animations for pushViewController, but in iOS 7 they're working not correctly.
I'll let someone else help you with the back button issue because I think it's a mistake to create one for a modal view controller that's presented from the bottom of the screen. Typically, such a modal view controller is dismissed with a cancel button or its equivalent. If you really think that you need a back button then you should probably push the view controller onto the existing navigation stack instead of presenting it modally.
However, I am happy to show you how to properly alloc/init a navigation controller and then present it.
I don't know why you're subclassing UINavigationController, but I'm going to pretend that you don't need to (which is probably the case).
InfoRootViewController *rootViewController = [[InfoRootViewController alloc] initWithNibName:#"InfoRootViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[self presentViewController:navController animated:YES completion:nil];

How to open an UIView in fullscreen mode with a tabbar?

this is my problem.
I have a tabBar application.
In first tab, i have a table.
On click on table it shows a modal
view.
To go back from modal view to first
view, i use
[self presentModalViewController:nw animated:YES];
The problem is that if i click on the tabbar while is opened a modal view, it opens second view, but first view's table don't work because the modal view is still opened althoug it appear as closed.
It's a way to open modal view in fullscreen covering the tab bar?
Or also to check if modal view is closed or not from another view?
EDIT:
I tried with all of this code:
nw = [[NewsViewController alloc] initWithNibName:#"NewsViewController" bundle:nil];
nw.modalInPopover = YES;
nw.wantsFullScreenLayout = YES;
nw.hidesBottomBarWhenPushed = YES;
nw.contentSizeForViewInPopover = CGSizeMake(320, 480);
nw.modalPresentationStyle = UIModalPresentationFullScreen;
nw.view.frame = [[UIScreen mainScreen] applicationFrame];
[nw.view setNeedsLayout];
but nothing!!! It wan't go in fullscreen!!
Any idea please?
thanks,
alberto
If the view you're presenting is full screen, this should obscure the tab bar. That said, you might need to re-size the view programmatically so that it's the same size as the UIWindow.
You should be able to do something along the lines of...
[nw setFrame:[[UIScreen mainScreen] applicationFrame]];
[nw setNeedsLayout];
...to achieve this. (Sorry, I'm on a Windows box at the moment, so I can't confirm this. Hopefully someone will provide any tweaks if required.)
You should then dismiss the initial modal view via a delegate method in the originating class. (See the "Dismissing a Modal View Controller" section of Apple's View Controller Programming Guide for iOS.) The originating class would then dispose of the modal view.
Resolved using notification!
When a tab change, i send a notification and close the modal controller.
- (BOOL)tabBarController:(UITabBarController *)tbController shouldSelectViewController:(UIViewController *)viewController {
[[NSNotificationCenter defaultCenter] postNotificationName:#"DataComplete" object:nil];
return YES;
}
In my view classes receive a notification and dismiss the controller!
- (void)downloadDataComplete:(NSNotification *)notif {
NSLog(#"Received Notification");
[self dismissModalViewControllerAnimated:YES];
}
Now it's possibile to reopen a modal view also changing tab!
This is a workaround but works!
alberto.

Hide the tab bar in a tab bar application

I have created a new project from the template:
IPhoneOS>Application>Tab Bar Application.
I get two tabs.
How can I make the second become a full screen hiding the tab bar and even the status bar?
I tried to check the "Wants Full screen" - but it didn't help.
(Much less important... When I do get a full screen I do I get back?)
Please give me a simple code/guidelines or a reference to them, cause I'm a beginner - and Me and the compiler got too many issues to make things worse
Thanks
Asaf
To hide the tab bar you can use hidesBottomBarWhenPushed. For instance:
MyController *myController = [[MyController alloc]init];
myController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myController animated:YES];
[myController release];
To hide the status bar you can use:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
To hide the nav bar you can use:
self.navigationController.navigationBarHidden = YES;
You can just use:
//Navigation bar:
self.navigationController.navigationBarHidden = YES;
//Statusbar:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
//Tabbar:
self.tabBarController.tabBar.hidden = YES;
Have you checked Modal View Controllers out?
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html
Try the presentModalViewController:animated: method on your navigationController (instead of pushing a view controller)
[self.navigationController presentModalViewController:foo animated:YES];
Another way to accomplish this is by making the UITabBarController the rootViewController of a UINavigationController. Then when you pushViewControllerAnimated: the tab bar will slide away with the root view controller.