Setting up iOS Navigation Elements - ios

I am having difficulty figuring out how to set up my UINavigationController to get the result I want. Most succinctly, I want to mimic the navigation of the app BriefMe.
Specifically, I want:
a main view (v#1) that segues to a new view controller (v#2) with an embedded UIWebView
to permanently hide/disable the navigation bar and toolbar on v#1, but I do want a toolbar on v#2 (ideally which shows/hides on swipe -- I figure this can be solved with a UIGestureRecognizer if not through the NavController's hide on swipe/tap property)
v#2 to segue back to v#1 on a swipe from the left edge of the screen, just like the default NavController behavior, shown here.
I've run into two problems with my attempt to set this up:
I can't permanently hide the navigation/toolbar on v#1 while leaving v#1+#2 embedded in a NavController. Without the NavController, I don't retain the swipe-to-segue functionality when v#2 is at the top of the stack
Allowing the WebView to scroll disables/'intercepts' the swipe-to-segue functionality. My only thought is to disable interaction with the WebView, place the WebView in a ScrollView, and allow only vertical scrolling on the ScrollView. Will this allow the swipe-to-segue to work?

If I understand your questions correctly:
We’re still popping a controller from the stack during the transition. We just add the navigation bar as a subview of the controller’s view at the top of the stack and then set up the back event manually.
We ended up using a version of the answer specified here. We added an extra invisible thin column overlaying the left side of the webview because some webviews were still giving us trouble.
Hope that helps!

Related

iOS / Swift - Swipe/Drag between ViewControllers like Telegram/iOS Settings

so I already searched a lot but maybe I missed something.
I would want to be able to drag a view to the side and drag a new view from the left.
Like in Telegram where you can slide between chats overview and a chat itself or in the iOS Settings where you can slide right and drag the detail view to the right and the overview is coming from the left.
I do know how to do segues with a slide animation, that's not what I am asking. These segues are started ones and can not be controlled by the user.
I did not use a navigation controller behind my bottom bar controller so I had the wrong transitions. When using the native Navigation Controller on all subviews of the bottom bar navigation controller you can control toolbar items and the "slide" I mentioned.

How to make titleView remain in UINavigationBar during push/pop transition like Facebook app?

Here is a transitioning animation of UINavigationBar used in Facebook for iOS:
The topViewController is being changed, but the titleView is transitioning seamlessly.
(For your information, the two textfields are the same instance (checked with FLEX). However, I don’t care if the two textfields are not the same instance.)
What's the best way of approaching this?
Thanking you in anticipation.
I'm fairly confident that is not a navigation push/pop. I suspect what they're doing is hiding the left bar button to make the search field larger, and then just adding a view on top of the current VC's view. When you cancel, they hide the view and show the bar button. The clues I'm using to draw this conclusion are that (a) I've been writing iphone apps for years and I have no idea how to make a nav controller/bar do what you want with a push/pop, at least not without a lot of faking it and hoop jumping, (b) you video has the new view "pushing" from the wrong side, and (c) in my copy of the FB app, there is a different animation where the second view just appears/disappears without any push/pop animation.

Xcode 6 - Swift - Custom Tabbar with Navigation

I'm trying to create a tabbed application with navigation elements inside the tab bar, as seen in the picture below (the red bar) using Swift/XCode 6.2. Basically those three icons in the middle will direct the user to different view controllers. The other two icons would be context-based. For example, on a table view page you would see the menu icon and add new icon as seen in the image. However, clicking on a row would change the menu icon to a back icon, and the add icon to something else.
That's the general idea, but I'm having a very hard time implementing something even close to this. The first issue is that whenever I embed a view in a Tab Bar Controller, I can't move the tab bar to the top. However, when I create a custom UITabView in a View Controller, Control + Click and dragging a Tab Bar Item to another view doesn't create a segue. I haven't even begun to tackle having the navigation elements inside the bar.
I guess what I'm asking is just for a little guidance on what route to take to tackle this. I'm assuming I can't use a Tab Bar Controller or Navigation Controller because it doesn't seem like I can customize them all that much. So custom Tab Bar and Navigation Bars, and then implemnt the segues and button changes programmatically?
Thanks.
I will try to guide you from an architectural perspective (so you won't find much code below).
Using a UITabBarController
In order to achieve what you are suggesting, you are right you cannot use a UITabBarController straight away, among several reasons, the most immediate one is that they are meant to be always at the bottom and you want it in top (check Apple's docs). The good news is that probably you don't need it!
Note: If you still want to go with a UITabBarController for whatever reason, please see #Matt's answer.
Using a UINavigationController
You can use a UINavigationController to solve this task, since the UINavigationBar of a UINavigationController can be customized. There are multiple ways on how you can organize your view's hierarchy to achieve what you propose, but let me elaborate one option:
To customize a UINavigationBar's to add buttons, you just need to set its navigationItem's title view:
// Assuming viewWithTopButtons is a view containing the 3 top buttons
self.navigationItem.titleView = viewWithTopButtons
To add the burger menu functionality on a UINavigationController you can find several posts on how to do it and infinite frameworks you can use. Check this other SO Question for a more detailed answer (e.g. MMDrawerController, ECSlidingViewController to mention a couple).
About organizing your view hierarchy, it really depends on if when the user taps one of the main top buttons, it will always go to the first view controller in the new section or if you want to bring him back to the last view in the section where he was.
3.1 Switching sections displays the first view of the new section
Your app's UIWindow will have a single UINavigationController on top of the hierarchy. Then each of the 3 top buttons, when tapped, will change the root view controller of the UINavigationController.
Then, when the user changes section, the current navigation hierarchy is discarded by setting the new section view controller as the UINavigationController root view controller.
self.navigationController = [sectionFirstViewController]
3.2 Switching sections displays the last displayed view in the new section
This will require a slightly modified version of the above, where your each of your sections will have its own UINavigationController, so you can always keep a navigation hierarchy per section.
Then, when the user taps one of the top buttons to switch section, instead of changing as previously described, you will change the UIWindowroot view controller to the new section's UINavigationController.
window.rootViewController = sectionNavigationController
Using a custom implementation
Of course, the last and also very valid option would be that you implement yourself your own component to achieve your requirements. This is probably the option requiring the biggest effort in exchange of the highest customizability.
Choosing this option is definitely not recommend to less experienced developers.
I'd like to take a stab at this--I think it is possible to use a tab bar controller here.
Your topmost-level view controller will be a UITabBarController with a hidden UITabBar.
Each tab is contained in a UINavigationController.
All view controllers in the navigation controller will be a subclass of a view controller (say, SwitchableViewController).
In SwitchableViewController's viewDidLoad, you set the navigation item's title view (i.e. whatever's at the center; self.navigationItem.titleView) to be the view that holds the three center buttons. Could be a UISegmentedControl, or a custom view.
Whenever you tap on any of the buttons, you change the topmost UITabBarController's selected index to the view controller you want to show.
Issues you may encounter:
Table views inside tabs will have a scrollIndicatorOffset at the bottom even if the tab bar is hidden.
Solution: Play around with the automaticallyAdjustsScrollViewInsets of the tab bar controller, or the inner view controller. https://stackoverflow.com/a/29264073/855680
Your title view will be animated every time you push a new view controller in the navigation stack.
Solution: Take a look at creating a custom transition animation for the UINavigationController.

Custom View at the bottom of navigation bar

I need to add a custom view just below the bottom of navigation bar. My requirement is that when certain condition meets, I need to show a view of 80 height which needs to be sticky, for all remaining subsequent screens. Its like what music streaming apps pandora, Spotify have it when you start playing a song but it is at the bottom, but I need to have a view at the top. Any helps
I am not entirely certain about all the mechanics of how you would do it, but You may want to start by adding the view that will have this sticky content to the root viewController or navigationController, and do it like suggested in this post:
iOS Floating Video Window like Youtube App
So, this is how I solved it, but instead of custom view at top, I end up showing at bottom only, requirements changed. To do that I was maintaining a root view controller which has tab bar inside it, and it also has custom view, so it was easy to manage that by this hierarchy, as root view controller can easily show and hide the view, and also it remains persistent irrespective which tab user go. But I still don't know how to do at top, which was original requirement.

Page curl modal segue : leave bottom bar on screen

I develop an app for iOS 5+ with storyboards (and ARC). I have a view controller with no status bar, a top navigation bar, a map in the middle, and a bottom toolbar with a button at the bottom right. I've linked the button to a modal VC via a page curl segue.
My problem is I would like the page curl effect to apply only to the map (just as iOS 5's map), or at least not to the bottom toolbar, so I can present/dismiss the modal VC with the same button of the bottom bar (I want it to be persistent). Right now, I can present it by pressing the button, but the toolbar goes up halfway of the screen with the whole view. I can dismiss it by touching the upper-left side of the screen but it's not really user friendly.
I can add the toolbar to the modal view controller, but that doesn't look nice...
Any ideas ?
Thanks.
A quick thought for you as I stumbled on this while looking for something else, but I would consider:
Putting the top section of the screen within a container view, then presenting the modal view from that. It will leave the bottom (toolbar area) clear.
Alternatively, instead of using the standard segue you could implement your own page curl, and/or using some of the open source projects that demonstrate how to do this.
You probably solved this long ago but perhaps this helps someone :)

Resources