Slide out menu - When switching back to original controller, Nav bar disappears - ios

I have a slide out menu in my app, and just to let you know, I'm new to iOS/Swift, so if I don't explain it well, or use the correct terms, that's why.
I use the SWRevealViewController library for my sliding out menu.
The only code i use from that for all my View Controllers is
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
The issue basically is, when the app first opens, it shows my navigation item's title and all that on ViewController1(default view), but when using the slide out menu to go to ViewController2 or 3, and then going back to the ViewController1, the whole navigation bar/item disappears.
I tried to use something like nav_item.title = "whatever" within viewDidLoad(), but that doesn't work, as far as when i switch back to the first view. The funny thing is, if i programmatically change the title doing that, it changes when it first loads but when i change to View2 and change back to View1, just disappears.
Here are a few images of what i mean, if i didn't explain it well enough, because like i said i'm still new. The development of my app is coming along pretty well because i'm going off my android version i've had done for a while.
Here is when it first loads, title and all. Notice, my background color doesn't overlap or change the top part for the time and battery, which becomes a problem with the later view.
Switched to a different view using my slide out menu.
Switching back to to the original view, the nav item disappears and the background color extends to the full view, overlapping the battery status and time

How does your Storyboard look like? This is how I usually do it.

Related

iOS - Customize Navigation Bar for only some UIViewController

I have to add new screens to an existing app, that will use a different navigation bar style than the one that already exists and will be accessed from different screens. The idea would be to show the new Navigation Bar style only for those screens, so when the user finishes that flow or goes back to the screen that started the navigation, it should show again the navigation bar style it was previously using.
I have tried 2 things but didn't work as expected:
I thought of wrapping the new screens in a new UINavigationController, so I could change its navigation bar style and it would be consistent for the new screens. It works but the problem is that I am not able to customize the initial UINavigationController transition to make it not look like a modal (i.e I want to show that UINavigationController with the same animation as if I were pushing a UIViewController). Is there a way to do that? By the way, I am managing the navigations with storyboards segues.
I also thought of using
self.navigationController?.navigationBar.isHidden = true
But doesn't seem clean because I would have to show it again when the flow is finished (it is a bit long) or cancelled. This makes a lot of combinations and it would be easy to miss one of them, so this doesn't seem a practical solution. Is there a better way to do this?
The presenting view controller is where you want to change the nav bar for the controller to be presented. So you'd make any changes to the navbar just before you call push(viewController:animated:).
And then in viewWillAppear of still the presenting view controller you would reset the navbar to what it was initially.
NOTE: Keep in mind that depending on the kind of changes you're doing to the navbar, the transition might no longer be smooth. The user might see some flickering of sorts on the navbar, which would be poor UI/UX.
Edit: Another alternative
Alternatively, you could get rid of the navbar and instead implement your own header view that you can style however you want, to represent the navbar.
You can style it as a simple navbar with a title + back button.
You can style it to look like a navbar with large title
You can style it as a navbar with back button + background image + title + right bar buttons
As you can see, this second alternative offers you more freedom in what you can do.

Transition of a view controller embedded in a navigation controller

I have a problem with a transition. I am modifying this project https://github.com/xxxAIRINxxx/MusicPlayerTransition in order to have the transition from the right instead of the bottom. This part is fine. My transition comes from the right.
My problem is that I'm embedding the presented modal view controller into a Navigation Controller. I do this so I can use the "pushViewController" function when I click on a cell of my modal view controller.
My hierarchy is as follow. I have a dashboard. From the right, I drag a TableViewController X. If I drag back in the opposite direction, I come back to my dashboard. Fine. Now, If I tap a cell, it pushes a new ViewController Y.
Now, if I am in my new ViewController Y and that I drag back, I come back directly on my dashboard instead of going back to my TableViewController X, as a natural navigation controller should behave.
I did a small project on github that does only that, so you can easily see my entire code.
https://github.com/magohamote/NavigationControllerTransition.git
I understand why it behaves like this, but I would like to know how I can override the transition set on the navigation controller in order to have the normal behaviour of my navigation controller once it is presented.
Another problem I have not been able to solve. On the project I used as a starter (the one from xxxAIRINxxx) the transition is perfectly smooth. On mine, the first time I trigger the transition, it blinks and get stuck. Once I did it once, it is smooth the next time I drag my view. But the first time is always awful. I don't know why either :(
Thank you a lot for your help!

-hidesBottomBarWhenPushed causing issues when used in Nav Controller

I'm having weird view controller issues when using the -hidesBottomBarWhenPushed property. This is an iOS 7 only project. Using Xcode 5.whatever is latest. No betas.
There are several issues, but I think they are all surrounding the same issue. Here are my different use cases.
Both Use Cases start with the same layout. UITabBarController (2 tabs) --> UINavigationController (Tab1) --> Tab2 (not needed for example) --> set as rootViewController on my application window.
Use Case 1:
ViewController1 - Has navigation controller and tableview with content. Push a view controller that does not need the tab bar (uses toolbar with custom content).
ViewController2 - Tab bar is not showing, things look great so far. Now I need to push another view controller that needs the tab bar again.
ViewController3 - Tab bar is showing, things are still good to go. One more level to go, tab bar still needs to show.
ViewController4 - Tab bar is missing. Not good. This sucks, lets back up.
ViewController3 - Tab bar is now gone here too. View takes up full space, that is good, but no tab bar. Back we go.
ViewController2 - What the eff? My toolbar is shaded and can't be selected, and the view is sized like there is a tab bar there. I can scroll content and see where it thinks the view ends. This view is toast, back to home.
ViewController1 - Everything is back to normal. Tab bar showing no problem. I can drill back in with no issues going in, but coming back, everything is hosed pretty bad.
Use Case 2:
We can skip a view and get similar results.
ViewController1 - Same as Use Case 1. Our home view, where everything is working and looks great.
ViewController3 - Lets skip the toolbar view and keep our tab bar in place. No sweat. Tab bar shows up fine. Looks good, lets drill in one more level.
ViewController4 - The hell? Tab bar is here, but it looks shaded or selected. Content is offset up from the tab bar, it doesn't line up with the tab bar. About the same height as the tab bar. If we toggle tabs, the tab bar loses its shaded state. Come back to same screwed up view... looks fine now. The table view here is now nested perfectly on top of the tab bar. I give up!!
ViewController3 - The tab bar here looks fine at least. Whew! One less thing to fix.
ViewController1 - Home still looks good. Please don't ever leave me home view.
Those are the steps I take. Now for how I'm pushing these views.
ViewController1 - Does most of the heavy lifting. Due to examples and fixes from other questions, is setting the -hidesBottomBarWhenPushed property before pushing views out the door.
All View Controllers have a property set during init, self.hidesTabBar; YES hides it, NO shows it.
ViewController2 alloc/init; // normal init stuffs
// set current view property to the property on next views property (set in init of view)
[self setHidesBottomBarWhenPushed:ViewController2.hidesTabBar];
[self.navigationController pushViewController:ViewController2 animated:YES];
// set back after pushing to what the current view needs to be at
[self setHidesBottomBarWhenPushed:self.hidesTabBar];
This method continues for all views being pushed onto the nav stack. Basically, before I push, I set my current view -hidesBottomBarWhenPushed property to the same as the view I'm about to push. After I push, I set it back to what it was before I pushed.
I have tried every combination of setting this and I end up with problems all over. I need to be able to control when the tab bar gets shown. Some cases it will always be up. Some it will show/hide/show/show, and every combination in between. The only constant is that it will always be shown on the root/first view of the navigation stack. After that, it all depends on the path the user takes. Help!!!
After filing a radar, it seems that Apple has acknowledged that this is a bug in iOS 7. They are reporting it is fixed in iOS 7.1b4. I have also confirmed this is fixed in that build as well.

Tabbar not showing in ios application

i am making one iOS tabbar application in that i have put 4 different tabs and whenever i click on 1 st tab and load another view after clicking of the first tab. After that when i press back button then tabbar is not displaying .So that i want hint that how can i show that
back the tabbar when we move from one tab from another and yes how i can use consistent the tabbar in whole application can you just guys help me on this i am new to iOS development.
here i am put the screen shot ...
here first screen is this one..
when i tap the video button that are first in the view then another window open
which are as under and see the tabbar is not there...
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Looking at your screen snapshots, do I correctly assume you're attempting to transition to the "Videos" scene by touching the big "Videos" button in the center of the "Home" scene (rather than touching the tab bar button at the bottom of the screen, which I assume works fine)? If that's the case, you need to have your button tell the view controller's tab bar controller that you want to change the index of the tab bar, and it takes care of it for you. You cannot do the transition using a segue (or at least not without a custom segue, which is even more complicated than the procedure I outline below). If you're changing the view some other way (e.g. using a standard segue or using presentViewController, pushViewController programmatically, etc.), your tab bar can disappear on you.
You later said:
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Yes, that's true. You cannot use a segue from one of your big buttons to one of the tabs in your tab bar. (Or technically, if you wanted to use a segue, it would be a custom segue which would do something very much like my below code, though perhaps a tad more complicated.) So, rather than using a segue for your big button, you need to write an IBAction (connected to the big Videos button on the Home scene), that tells the tab bar to change its selection:
- (IBAction)clickedVideosButton:(id)sender
{
[self.tabBarController setSelectedIndex:1];
}
A couple of comments:
My answer was predicated on the assumption that your tab bar works as expected when you tap on the buttons of the tab bar, itself. If you tap the buttons at the bottom of the screen, do you transition to your other views correctly and preserve the tab bar? If so, my answer above should solve your issues in getting the big buttons to work. If not, though, then the problem rests elsewhere and you need to show us your code that might account for that (either you're something non-standard in the UITabBarControllerDelegate methods, or your viewDidLoad of the view is doing something nonstandard).
If I understand your user interface design right, you have the tab bar at the bottom as well as the big buttons in the middle, which presumably do the same thing. That is, no offense, a curious user interface design (duplicative buttons, requiring extra tap on a button, etc.). You might want to choose to either use either big buttons (in which you can retire the tab bar, eliminate the IBAction code I've provided above, and just use a nice simple navigation controller and push segues, for example), or just use the tab bar (and lose the home screen, lose the big buttons, etc.).
You also made reference to "press back button", and I don't see any "back" button on any of your screen snapshots. Do I infer that you have a navigation controller and you're doing a pushViewController or push segue somewhere? If you're doing something with back buttons, you might need to clarify your question further.

UISplitView having issues in Portrait

I have a UISplit-view that uses Table-views in the left hand "Master" area and it seems that after pushing several table-views on the Root Controller, followed by popping them off and all the meanwhile, rotating back and forth between portrait and Landscape, the button in portrait seemed to stop responding.
Upon further investigation, it turned out that it wasn't that it wasn't not-responding, it was that the area that was touch sensitive was sliding partially off the screen making the area that you could touch to get the "Master" popover was at the very Edge of the button making it extremely difficult to hit. I do have a flex space, title, and additional logout button.
Any Ideas?
It turns out that in the Mono-touch split-view template, has two methods in the Detail Controller, in one it hides the popover and button for the Master view while in Landscape, and in the other method it puts it back. I was using one of those methods to add a fexible space item, text item, and logout button to the toolbar. The problem was that because I was doing it in that method, it was adding them every time it went to portrait and somehow the flexible space getting added every time, was slowly pushing the touchable area for the Master Button, off the screen. (The Button itself never moved) After adding the items to the toolbar during the ViewDidLoad method, and not adding it again, resolved the issue.

Resources