Xcode segue leads to back screen sometimes - ios

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.

Related

For swift iOS app dev, how do I segue to a view that takes up part of the screen only?

GroupMe is a good example. I want to implement something similar to this..
when you press the top left icon it'll bring you to the view on the left hand side, and when you click the right hand side of that view (the chats) it will bring you back
As the documentation says:
Use segues to define the flow of your app’s interface. A segue defines
a transition between two view controllers in your app’s storyboard
file. The starting point of a segue is the button, table row, or
gesture recognizer that initiates the segue. The end point of a segue
is the view controller you want to display. A segue always presents a
new view controller, but you can also use an unwind segue to dismiss a
view controller.
As said by Apple© segues are for changing View Controllers only and cannot be used to move single views. I suggest using animations to achieve the effect you are searching, however segues are definitely not what you are looking for. Maybe this question on stackoverflow.com may help you.
And please be sure to check for information by yourself first, I got this information in less than 5 minutes by searching on Google.com.
Regards -Jorge

Popover View Does Not Show Subviews

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.

Second tab is always a black screen

I have a UITabBarController that has 2 items. Each of them points to a different UINavigationController, however both of them point to the same UIViewController. The first item is displayed correctly but the second on is not. What's happening.
No code is necessary for reproducing it.
A view controller can't be in different navigation controllers at the same time. You need two scenes here. This is one reason why I don't like Storyboards.

Swift loading ViewController on TableViewCell Design

As I understand it, one of the best ways of handling opening Views upon clicking a particular tableViewCell is by pushing to the ViewController.
However, this apparently only works if you only embed the ViewController in a NavigationController.
Would you then have to embed each individual ViewController in an Navigation Controller?
This sounds sort of repetitive and tedious - is this good practice?
This tutorial uses navigation controllers on all of the view controllers, but doesn't really say why
I just use one navigation controller, and it works fine for me. I've used one and had segues between multiple viewControllers including several tables as well as using buttons in some places, and still been able to navigate super easily. In main.storyboard, just select the first view that's going to be a part of it, then go to Editor>Embed In>Navigation Controller. Then, you just add in your segues (I believe they should all be Show(e.g. Push) segues to work correctly)
When running your app, there should be a bar at the top which can be used to go back (you can also edit the bar by adding other buttons or changing the color and title).
Here's some documentation from apple

Weird segue transition after disabling autolayout

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.

Resources