When animating a viewController on top, the one in the back disappears. - ios

I have a viewController which displays a map with annotations. When I click on a bar button, another viewController is supposed to animate on top of that. This works, BUT, when the animation completes, the viewController in the back disappears. It reappears again when the animated viewController closes again.
Here is a video of what happens - hopefully that will make things more clear:
Let me know if I should include the code as well.

When you present a view controller it is expected to take the full screen. As such, the view controllers 'below' it have their views removed from the stack to save resources which are expected to not be required.
You can change your presented view controller to do something like:
Either, don't be presented, just add a subview and animate it in.
Or, pass an image of the original view to the presented view, this becomes the background and that presented view animates a subview in over the image background.

Related

View Controller's Main View is sometimes under status bar, sometimes not

I have a View Controller with one main image covering the whole of the view, and a few buttons. When I get to this view through a push segue from the previous controller, the view is shifted downwards below the status bar, showing a black strip where the view is missing (and moving my buttons out of position).
When I show the next screen and dismiss it, the view shifts back to the correct position.
How can I make sure that the correct distribution of the view (second image) happens every time?
UPDATE:
This is how my storyboard looks:
I was able to fix this problem with a simple line of code:
self.automaticallyAdjustsScrollViewInsets = false
By the way, this was happening to me on a UIPageViewController and this line of code was included in ViewDidLoad of that VC, not the Content View Controller.

InteractivePopGestureRecognizer not animating correctly

I have rather complicated structure of my UIViewControllers, so interactivePopGesturerecognizer behaves strange.
First, my VC hierarchy is as follows: I have a UINavigationController which is in AppDelegate's rootViewController VC. Then I push a VC which servers as a placeholder for 5 VCs on same level, i.e. those VCs are siblings which I use as VCs in infinite horizontal scroll system. I add their views to pushed VC. Now, each of those 5 VCs have UITableView and after pressing rows, those tables push details VC on stack. Details VCs are being animated just fine when being pushed to stack. Even when I hit back button on details VC, I see parent UITableView animating in the background. The problem arises when I try to swipe the details VC to pop it off stack. Then I get this, there is no UITableView in the background that animates.
So far, I've done this:
- in my AppDelegate.m I enabled interactive pop gesture navigation.interactivePopGestureRecognizer.enabled = YES;
in my details VC I set delegate self.navigationController.interactivePopGestureRecognizer.delegate = self;
When the animation finishes, i.e. details VC goes right off the screen, my parent VC with table magically shows up. This doesn't happen if I press button, in that case, that UITableView animates from left and stays in position.
I presume that since I'm having situation with horizontal scroll UINavigationController loses it's position after I scrolled to another UITableView so parent table is someplace else. But how come when I press the back button, I can see that table animating from left?
I also tried to explicitly add UITableView of current VC that is on screen to navigation stack by pushing it, but the problem arose when I tried to pop it of stack and show it again, it stayed invisible.
I don't want to have multiple UINavigationControllers because when I swipe them inside UIScrollView, I want my bar to be fixed in position.
So, main question is: how to have the same visual behaviour with interactivePopGestureRecoginzer as I get with back button for free (animated parent UITableView), considering the fact that I have 5 sibling VCs that are not part of navigation stack, but merely their views added to parent VC which is on navigation stack?
Thanks!

How to fade whole screen

I am presenting a temporary view on top of my view controller when a user does some action.
I want it to fade the screen - including the navigation bar, like UIActionSheet does.
I am presenting the view via the root view controller of the navigation controller, so my only problem is to fade also the navigation bar and not allow touches on it.
How can I do that?
You can add a semi-transparent view on the whole UIWindow and it'll look just as you described it. You'd probably want to add your temporary view there, too, because all actions will be blocked by the semi-transparent view.

present view on part of screen; disable surrounding views but keep them visible

When the user presses a button, a text view should pop up in the middle of the screen. Two requirements:
1) Whatever was displayed before should still be visible (except where covered by the text view or keyboard).
2) If the user taps outside the text view or keyboard, nothing should happen.
I thought that if I presented the text view in its own VC, that would address #2, because I think that's how modal presentations work. However, when I do this, even though I set the background of the text view's VC to transparent and tried reducing the frame, all I get is the text view surrounding by black. Nothing is visible behind the presented VC.
EDIT:
It has come to my attention that apparently when you use a tab bar controller, that object does all of the presenting, no matter what VC actually sends the present message to itself. I am using a tab bar controller. Maybe this is part of the issue and forecloses the option of using presentViewController. So I need a different method!
You can just add a transparent view the size of the whole screen and put your textView in that. The transparent view won't allow touches to pass through. Then whenever the user is done entering text, you can just remove that transparent view (and the textView along with it) from its superview.

Screen is not updating when segued from one view controller to another

I have a view controller (lets call it AViewController) which has a background image, buttons, etc. I also have a second view controller (lets call it BViewController) with its own set of buttons. When i transition from one view controller to another, the background image along with the UI Elements of the first view controller is being displayed in the second view controller. I am using a segue. I faced with problem before. What i did to correct it was change the background colour of the view from white to clear color. But it doesn't not seem to work in this case. (The BViewController contains a UIView in which the user can draw.)

Resources