iOS 7 - Presenting modal view controller selects first tab in UITabBarController - ios

I'm working on a UITabBarController-based application for iOS with Xamarin, and while making some relatively small changes for iOS 7.0 compatibility, I found a particularly annoying issue that I am unable to solve.
A number of the view controllers that make up the UITabBarController have areas that require another view controller to be presented modally, sliding up from the bottom of the screen. In iOS 6.1, everything works fine.
However, in iOS 7 I've noticed that when the presented view controller is dismissed, the UITabBarController underneath has been navigated back to the first (leftmost) tab. This is very problematic, since any progress or information entered is lost.
Has anybody experienced this issue or, hopefully, found a solution?

Embarrassingly, I found out the cause of the problem. In order to fix this issue: UITabBar appearance setSelectionIndicatorImage does not work on first launch iOS7
I had this code running in my UITabBarController's ViewWillAppear overridden method:
if ( Session.IsiOS7 )
{
this.SelectedIndex = 1;
this.SelectedIndex = 0;
}
This is being used to force the tab bar to display the selection indicator image, which it does not do by default in iOS 7. It also happens to cause this problem! I can't believe I didn't think of this right away.

Related

How to solve Google Maps sdk orientation issues using TabViewController

I started an iOS project for iPhone where I thought might want a tab bar. I later decided that I don't want it (I want the extra screen space) and I so I tried to delete the tab bar and set my main ViewController as the initial viewController in storyboard.
This caused a weird error where the device's orientation no longer adjusts properly. For instance, switching from portrait orientation, shown in the picture:
becomes this in landscape:
If you start the app in landscape, it will look fine, but there will be a similar result when you switch to portrait. The bug manifests in the transition between screen orientations.
I've tried the following:
I restored the tab bar and the problem went away. This problem is caused by how I am removing the tab bar and not some other issue.
I searched for other articles dealing with this issue. So far, I've only seen documentation on how to install a tab bar, not how to safely remove it.
I attempted to connect the tab bar to the viewController with an IBOutlet and then set tabBar.isHidden = true. It's a bad hack, but it didn't work anyway. UITabBar has no such member.
I've tried comparing the settings between the tabBar viewController with my desired initial viewController in the Inspector, to see what may be different. Aside from the initial viewController check-box, I don't see a setting that might be causing this.
QUESTION: Is this a settings issue in storyboard (or elsewhere), or is this just a bug? My next attempt at a solution will be to delete the entire storyboard, and then recreate it and connect it back to the viewController. That's a fair amount of work I'd like to avoid if it's unnecessary.
Any help is appreciated. If I find a solution, I'll make sure to post it. Thanks!
UPDATE: I've found a workaround by going to the UI Tab Bar Controller in the Storyboard, selecting tab bar in Tab Bar Controller Scene -> Tab Bar Controller, and then checking the 'hidden' box in the inspector. This has the desired effect of getting rid of the tab bar when the app is running. It's like it's not there.
While this allows me to proceed with the app, the tab bar stuff is unnecessary code lying around in my app that I would like to get rid of.
Since I originally made this post, I've found out through experimentation that the every time I added Google's GMSMapView to a viewController, programmatically or in storyboard, I was having the above orientation issues. My original problem wasn't what I thought it was
I have since tried completely rebuilding the storyboard, viewController and all, but the problem didn't go away. I also tried overloading the orientation methods for the view to no effect.
However, if you are having this orientation problem with Google Maps sdk, imbedding the view controller that contains your GMSMapView in a tab view controller, and then hiding the tab bar (unless you want a tab bar) fixes the orientation issue in my project. It's not pretty, but it works.

No tab bar in one child view since Xcode 9.2 update

Since I updated to Xcode 9.2, the tab bar isn't displayed anymore in one of my child views and I'm struggling to get it back.
I did everything using the storyboard.
Here is a screenshot of it:
As you can see, the same segue is used in both views but the result is not the same...
I ended up using a small workaround. Maybe it is the right way to do it and my first implementation was wrong.
So instead of embedding the tab bar controller in a nav bar controller I ended up putting each tab in a nav bar controller.
Like this:
screenshot
And now everything is working correctly.

In Xcode 6.1 I have two navigation buttons. But they are not visible on the Storyboard anymore. How do I get them back?

So I have been working on an app for a bit now. Very New to iOS Development and have started straight in with Swift. I have several view controllers with navigation buttons. The buttons were placed by me on the storyboards but have have since disappears from the storyboards. Although when I run the app they are still appearing in the application and still function as coded.
I can see them in the side panel but I can't see them on the story boards. I have included some screen shots..
Can any explain why they are not on my storyboard any more and how I can get them back..
"http://i.stack.imgur.com/fGmxM.jpg" - XCODE View
"http://i.imgur.com/1iwsmGd.png" - App View
Apologies for the links I can't post images on my first post...
Change your top bar simulated metric to Inferred
Top Bar: None
Top Bar: Inferred
Assuming that your UINavigationController was added via Editor > Embed In > Navigation Controller

View Controller in the "More" tab doesn't rotate, but it will if it's on the home row.

I have an app built in storyboard that needs to support landscape mode in just one view controller. I decided to support iOS 6 after some issues with supporting iOS 5 and running iOS 6 on my phone. I used this Stack Overflow answer: https://stackoverflow.com/a/12505461/1050388 but I'm still seeing a weird quirk. (For those interested, my controller scheme is Tab Controller -> Navigation Controller -> TableViewController -> UIWebView. The UIWebView is the only VC I need to rotate.)
I blocked all but one VC from turning, but that VC is in the "More" tab. I initially had a quirk where this "More" VC would change orientation to landscape when rotated and then any subsequent VC would be in landscape, but I found this (https://stackoverflow.com/a/12526152/1050388) and creating a category for UINavigationController helped to solve that issue.
However, when I navigate to that tab in the "More" list, and turn the VC, it doesn't rotate. But when I click "Edit" and move that tab to the home row of the initial 4 tabs, it rotates just fine. If I move it back, it doesn't rotate. Anyone have an idea why this is happening?
I believe the problem stems from the fact that the More navigation controller is generated dynamically by iOS and is read-only.
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITabBarController_Class/Reference/Reference.html#//apple_ref/occ/instp/UITabBarController/moreNavigationController
It would be great if the technique of using a custom category would work here but based on your experience I guess it doesn't.
I also need better control of orientations for More tab views. Please post anything you come up with. Thanks.

UIPageViewController and off screen orientation changes

My app is a tab bar application running on iPad.
One of the tabs contains a UIPageViewController, which I implemented pretty much as per the tutorial here: Implementing UIPageViewController programmatically – without storyboarding.
Everything works great, including rotation. However there is a problem - if I go to the tab containing the page view controller, then navigate to a different tab and change the orientation. Then navigation back to the tab containing the page view controller, it is now displayed incorrectly.
Rotating the device again, with the page view controller visible, fixes things.
I guess this is because
pageViewController:spineLocationForInterfaceOrientation:
is not called while that tab is not visible. Any ideas on how to remedy this?
I had the same problem and ended up doing the same workaround. When I was done I didn't really hate it though, because it allowed me to free-up the UIPageViewController and all of it's child UIPageViewControllers and all of their resources when the user wasn't actively using the tab.
I worked around this by re-initialising the UIPageViewController inside viewWillAppear:animated. Not ideal, but it works...

Resources