I have a very peculiar problem.
My setup is a UITabBarController with two UINavigationController -> UICollectionViewController children.
If I say navigationController.pushViewController(someVC, animated: true) in viewDidAppear, the view controller is pushed as expected.
However, if I say navigationController.pushViewController(someVC, animated: true) when a cell from the collectionView is tapped, the view controller appears, but there is no animation/interactivity when going back (I cannot slide, and the buy button makes the controller instantly disappear).
This is really frustrating because I can think of no explanation. Why would the animations and interactivity work when pushed from viewDidAppear but not when pushed from a different function?
Why on earth is this happening, and how can I fix or get around it?
Well I have not figured out what is causing this issue, but I did find a (rather inconvenient) solution: Set the tab bar items in viewDidAppear. Use a short splash screen or something until then.
I'm not sure what the original problem was, though, so it would be great if anyone else had any explanations!
Related
I know there are other questions that address this, but none of the other solutions will work for this situation.
I have a UITabBarController that contains a UINavigationController as a tab root.
I'm creating another UINavigationController, with a UIViewController as its root view controller, and presenting it modally with UIModalPresentationCurrentContext. The UINavigationController that presented this one sets definesPresentationContext to YES.
I change tabs and come back to the first tab. Then, I dismiss that UINavigationController, and the screen turns white (I think that's because the UITabBarController has a white background.)
Other questions suggest using UIModalPresentationOverCurrentContext. And, yes, that does solve the white screen issue. But I can't use that because viewWillAppear and viewDidAppear aren't called on the presenting view controller. I have code that can ONLY be run from those places. So, UIModalPresentationOverCurrentContext is a no-go.
I also can't use UIModalPresentationFullScreen or UIModalPresentationOverFullScreen because I have to display the Tab Bar while presenting modal window.
I will either have to use UIModalPresentationOverCurrentContext and somehow figure out a way to trigger viewWillAppear and viewDidAppear, or I need to use UIModalPresentationCurrentContext and fix the blank screen issue.
Can anyone offer any advice? I'm banging my head on my desk and am about to break something... >:(
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!
I have an iOS app that was created using storyboards with auto-layout. The View Controllers are in a navigation controller. Several steps down the navigation controller chain I have a button in VC1 that is connected to VC2 via a popover segue. When I tap the button, a popover view appears but is blank. I changed the background color of VC2 to see if the view was actually appearing. It was. No subviews were visible. I have created and recreated VC2. I have changed the sizes of the view, the subviews and the view controller. I have manually and automatically created restraints. I also created a test view controller outside of the navigation view controller. It behaved the same as the view controllers in the navigation controller.
Just to check if I was completely incompetent, I created a new project with a storyboard that had one VC. I placed a button in this VC with a popover segue to a second VC. It worked as desired. When the button was pressed a popover would appear and all subviews of the second VC would be visible. I tried placing the first VC in a navigation controller with no change. It continued to show the popover as it should. I have compared the two projects and I can't find what the problem is.
My question is this: Does anyone out there know of some hidden setting that would cause this behavior? or Any suggestions on what I'm missing here?
Well, after a whole lot of time (and even rewriting my project from scratch) I finally found the solution. Apparently, using size classes messes with popovers. To solve this solution, I turned size classes off completely. My app is iPad only so that worked for me. According to this thread: iOS8 Size-Classes and Popover Views you can also use the Any/Any size class. I was using Regular/Regular size class. I hope this helps someone.
I have two view controllers that are linked to each other via segues. Both segues are modal, and have identifiers. Both view controllers have storyboard IDs and titles. When I go to my second view controller (VC2) I sometimes get a completely black screen (except for, strangely, a UILabel which has its text updated by a NSTimer every second). I have to check/uncheck animated on the segue several times to get it to work again. I have no idea why this is happening. I tried switching the views programmatically, and the problem went away, but I'd prefer to use less code and I have to share data between the segues. Anyone have an idea?
Either try what Calvdeos is saying
Or Use Navigation controller. Push first VC in the navigation controller. Then upon user action, push second VC on top of it. Then when VC2 is done, pop it off the VC stack.
It really depends on what the flow is. If you expand on the logical flow, i can suggest better.
Thanks everyone. Managed to fix it. The UILabel that would show up under the black screen had a bad IBOutlet. I deleted that outlet and fixed it, everything worked fine.
I don't know how to explain this, it's really strange.
Ok think about two view controllers, the first one is a tableview controller and has a button in his navigation bar connected via push segue to the second view controller.
When pushing the button, the second view controller comes in from the right and at the same time pushes the first view controller out, to the left.
I wasn't using auto layout for my project but I've activated it to test something (I've just activated two constraints for two labels in the prototype cell). Then I've disabled the auto layout and now when I push the button on the first controller the second one comes in, but instead of pushing out the first controller, it slides on the back of the first one, that disappears only when the animation ends.
It's like if all the cells in my first controller become transparent during the transition.
I can't see anything strange in my settings so I don't know how to solve this.
Well, as Ryan said, it was one of those annoying problems where you dig around for 30 (for me it's been 90) minutes with no success and then find out how to fix it with a single click.
It turns out that the second view controller had a transparent background (don't know why), so reverting it to white solved the problem.
Thanks God I din't delete the storyboard to make it ex-novo.