EGOPhotoViewer and NavigationController - ios

I'm having a problem with EGOPhotoView library in my iOS app, and I hope someone of you can help me.
My app uses a NavigationController, but does not display the NavigationBar, because the navigation is managed my some custom control. The problem is when I show an image gallery with the EGOPhotoView library, which shows a NavigationBar appearing on tap: when I pop the EGOPhotoViewController, the NavigationBar is still displayed, but I don't want.
Can someone help me to fix this problem?
Thanks

You can set one of your classes (probably your app delegate) to be the navigation controller's delegate. Then, when the EGOPhotoViewController is popped, you can hide the navigation bar. E.g.
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if ([navigationController.topViewController isKindOfClass:[EGOPhotoViewController class]])
{
[navigationController setNavigationBarHidden:YES animated:YES];
}
}

Related

UINavigationController hide nav bar for single viewcontroller

I knew its a duplicate. But still having an issue and even when tried with possibilities didn't work. Hence posting the same to reach a solution. Hope to get help from you guys.
The initial is embedded inside UINavigationController. For the initial (the landing view) the navigation bar must be hidden. The other views when called from the landing view - must show the navigation bar.
I'm handling the hide & show of navbar in the landing view by overriding the methods of the view as follows:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Hiding the navigationbar hidden for the first page
[[self navigationController] setNavigationBarHidden:YES animated:YES];
}
// Even tried animated:NO & animated:animated
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
// Showing the navigationbar hidden for the first page
[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
While the app loads initially, the nav bar is in hidden state (as expected & working fine). When coming back to the landing view from the child view controller, the nav bar gets hidden after some seconds - the landing view gets loaded on to the ui screen.
I also tried using the navigationcontroller delegate method in landing view: navigationController: willShowViewController: animated:. But unable to reach the solution that i need.
Hence i provided the navigationcontroller delegate in one of my childviewcontroller and checked whether the childcontroller when popped is not in viewcontrollers of the navigationcontroller using if condition. When yes, then i provided the hide option of the navigationbar. but also failed to have the solution.
During surfed, there was a solution to handle with viewanimation. I tried and that too failed.
Again surfed, the solution provided across is to handle the similar issue with viewwillappear & viewwilldisappear. I'm blinked since the way i'm doing is similar to the proposed way. Even then unable to reach a solution.
FYI.. I'm using Xcode 6.3 and deployment target is 6.0 onwards. I'm using storyboard to manage views.
Please help me sort the issue... App loads is hiding the nav bar in landing page. But when landing page is loaded back from a child view then the nav bar gets hidden only after the landing page loaded on to the ui. I do need to get hidden of the nav bar as like when app loads, when the child view pops and the landing view gets loaded on the top of the controller.
If you want to hide navigation bar in the second view then don't try to manage in viewWillAppear and viewWillDisappear because I have faced a lot of problems by trying like that and it also effected the constraints. Just use delegate for navigation controller in appDelegate it is working fine for me.
self.navigationController.delegate = self;
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if ([viewController isKindOfClass:[LoginViewController class]])
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
} else {
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
}
Use this method:
[navigationController setNavigationBarHidden:YES];
So, if you are in some view controller:
[self.navigationController setNavigationBarHidden:YES];
More clarifications:
UINavigationController has a property navigationBarHidden, that allows you to hide/show navigation bar for whole nav controller.
Let's look at the next hierarchy:
--UINavigationController
----UIViewController1
----UIViewController2
----UIViewController3
Each of three UIViewController will have nav bar since they are in UINavigationController. For example, you want to hide bar into the second (actually it doesn't matter in which one), then write into UIViewController2:
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES]; //it hides
}
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO]; // it shows
}
Overwrite the delegate method in your custom UINavigationController class:
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[self setNavigationBarHidden:NO];
if ([viewController isKindOfClass:[SomeViewController class]])
{
[self setNavigationBarHidden:YES];
}
}
One advantage for putting it in your UINavigationController class is that you don't clutter your UIViewController class with code
Tested and works.
UPDATE
Create a UINavigationController subclass: f.e. MyNavigationController
In AppDelegate.h:
#import "MyNavigationController.h"
#property (nonatomic) MyNavigationController *navigationController;
Then initialise it in AppDelegate.m:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Probably some more code here
self.navigationController = [[MyNavigationController alloc] initWithRootViewController:yourRootViewController];
self.window.rootViewController = self.navigationController;
self.window.backgroundColor = [UIColor blackColor];
[self.window makeKeyAndVisible];
return YES;
}
Then overwrite the delegate method in your custom UINavigationController class
I have little to no experience with storyboards so not really sure how to setup a custom UINavigationController, but this is how I do it in code.
Here's another SO post how to create a custom UINavigationController to use with storyboards.

UITableView reloads data, when pushing a new viewController

I have the following VC hierarchy: ParentViewController -> Navigation Controller(child VC) -> ViewController(with UITableView).
I am meeting the following issue:
In UITableViewDelegate.didSelectRowAtIndexPath, the app is pushing a new ViewController on the stack. The problem is that at this stage, the table view is automatically reloaded, without any explicit call to reloadData. This fact creates several issues, for example on return to the screen(with Back button) the table view is scrolled at the beginning instead of being focused on the selected row.
Could you please help me find why is it doing like so, is it a bug, or how to fix the issue?
UPDATE: I have just tested the same case on iOS 7.1 and there is no issue like that, I mean pushing a viewController, than poping back to the viewController containing the UITableView does not loose focus of the selected row.
hope this could help you.
My solution is to use navigationviewcontroller delegate, save selection when will push another one, and set back when pop back.
My sample code(I have set table view controller as delegate)
static NSIndexPath* path = nil;
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (viewController == self)
{
[self.tableView reloadData];
[self.tableView selectRowAtIndexPath:path animated:NO scrollPosition:UITableViewScrollPositionMiddle];
}
}
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
path = self.tableView.indexPathForSelectedRow;
}

Disable Edit Button in ios tab bar

I know that it was a old question but i can't solve it. I made a Tabbar controller with seven tab item in storyboard with tab bar controller not in custom tab bar so, i want to hide an edit button on more section of tab bar.
for that i code as:
on application didFinishLaunchingWithOptions: method
_tabbarconroller.customizableViewControllers=[NSArray arrayWithObjects:nil];
and also add a method
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UINavigationBar *morenavbar = navigationController.navigationBar;
UINavigationItem *morenavitem = morenavbar.topItem;
morenavitem.rightBarButtonItem = nil;
}
but it is not working in iOS7 please give me answer or any resource for this,
Use UITabBarController's customizableViewControllers property to make it nil :
yourTabBarController.customizableViewControllers = nil;

iOS - NavigationBar showing on child controller, hidden on parent controller

I have implemented a custom version of a search form that behaves a lot like a UISearchBar with a scope bar (but is actually pieced together programatically for UI reasons). The screen loads with a TextField, you tap in the TextField and the navigation bar animates up off the screen, the text field moves up and a segmented control appears for filtering results.
Anyway, that all works, but when I tap on one of the search results my code pushes a new ViewController. The problem is that new controller gets pushed without a navigation bar (because I used [[self navigationController] setNavigationBarHidden:YES animated:YES] when switching to the search state).
I can show the navigation bar as the new ViewController gets pushed, or even animate it in as the transition to the new ViewController appears - but all those solutions look clunky. I want it to work as if you were using a UISearchBar (actually more like the email app) in that the restored navigation bar appears to just slide in from the right as if it's part of the child view controller.
I'm hoping there'll be a simple fix... thanks
For anyone that comes to this, the solution is to make your controller the delegate of the UINavigationController, then show or hide the nav bar in your delegate methods.
Your controller needs to implement the protocol:
#interface MYSearchController() <UINavigationControllerDelegate>
Then in -(void)viewDidLoad assign your controller as the delegate:
[self navigationController].delegate = self;
Finally, implement a method like this:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if(viewController == self)
{
if(_searchState && ![self navigationController].navigationBarHidden)
{
[[self navigationController] setNavigationBarHidden:YES animated:YES];
}
}
else
{
if([self navigationController].navigationBarHidden)
{
[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
}
}

NavigationBar overlaps Statusbar for nested UINavigationController when hiding one navbar

I'm running into what seems like buggy behavior. I have one UINavigationController, which contains a tabBarController within it. That tabBarController has more than 5 tabs, so there is a more button, which loads the MoreController navigationController. Of course, that creates nested navigationControllers, so I want to hide one of the navigationBars.
I do that by making my ApplicationDelegate a UINavigationControllerDelegate:
[[tabBarController moreNavigationController] setDelegate:[UIApplication sharedApplication].delegate];
And implementing:
(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
navigationController.navigationController.navigationBarHidden = YES;
}
However, I end up with the Status bar overlapped:
Now, if I add some code to fix the frame manually, there's still some weird color overlay on the status bar, and now a black gap underneath the navigation bar. What gives?

Resources