Segues are not tidy - xcode

When I create a new segue using the storyboard (ctrl+drag), it creates creepy lines on my otherwise tidy clean storyboard... I was wondering if there is any method to make them prettier 😅😅
https://ibb.co/iHt9N8

First off. It looks like you are using segues incorrectly. You should not be using segues to go backwards. You should use a segue forward and then dismiss backwards without segue.
Remove any segues that you are using to “go back”.
Next, if it is still too untidy. Separate your app into different areas and use a storyboard for each area.

If you are dealing with a lot of storyboard view controllers, you cannot keep your storyboard clean.
Don't use segues. Just create an instance of the storyboard view controller programmatically and push/present it. Refer to this answer.

Related

XCode (Swift 3): Not showing NavigationBar in ViewController

I'm trying to show a NavigationBar with a Bar Button Item.
I drag and drop the elements in the StoryBoard and press Reset to Suggested Constraints, but the NavigationBar doesn't appear.
I tried setting the constraints manually in a different ways but can set it right.
There is a way to use layouts instead of constraints? In Android it is more simple, but using XCode and Swift I always have problems with the UI.
The segue that appears in top of the ViewController comes from a SWRevealController. That segue has sw_front as identifier, and class SWRevealViewControllerSegueSetController.
Please give some ideas about how to fix it.
Well, I fixed it some days ago.
In conclusion:
It is better to generate the NavigationBar creating a segue from the root of the NavigationView to another ViewController.
At least for me, the SideMenu is a better option (instead of SWReveal): it is more clear to get it working without a lot of changes in the StoryBoard: https://github.com/jonkykong/SideMenu

Linking actions to buttons on a modal/popover segue (swift 2 Xcode 7)

I'm sure I'm asking a simple question but I've only just started coding... so take pity on me!
I'm trying to figure out how to connect buttons (actions) to the viewController.swift from a modal/popover segue (I think the solution is the class but whenever I change it I get an error).
Eg.
In the storyboard, on the viewController interface, I have a button for sharing files. When I click it, a popover segue appears with two buttons on it, one for Fb one for Twitter, but I can't connect any actions from them to the viewController.swift
In another project I made a Google+ login and connected it to a modal segue but I couldn't make that work either.
Is segue the wrong thing to use?
Thanks for your help!
Marie
Your question would be easier to answer if you'd provide the actual error you're getting when you try to change the class.
It sounds like you're trying to connect the popover's buttons to actions in the presenting view controller (that is, the view controller that presented the popover), rather than the view controller of the popover itself. If that's the case, then that's the problem. You can only connect your buttons directly to actions available in the current scene.
This means you need a custom class for the presenting view controller (the one with the button that segues to the popover controller) and one for your popover. Set each scene view controller's classes to the appropriate custom classes you created (which must be a subclass of NSViewController or one of its subclasses or you won't be able to set the class name in IB) and you should be able to drag connections.

In Xcode, how do I create an outlet for a button that is inside a container?

I'm a total newbie with xcode and swift, trying to wrap my head around ios programming.
I'm designing a storyboard for my app. The storyboard uses containers to keep track of the controls. In one of the containers resides a button. I want to create an outlet for it to add some code when it is clicked.
If the button would be on the base viewport of the storyboard, I would control-drag a blue line from the button to the source window with my UIViewController subclass file, and it would assist me in generating the code. But for some reason when the button is in a container, this just doesn't work.
When following the documentation, it says to open the assistant editor when the button is selected and it should open the relevant file. So it open an objective-c file, but when I try to control-drag into it, it informs me that I do not have write permissions. Also I feel like I should be doing it in a subclass instead.
I have searched online a lot and tried everything I can think about, but nothing has worked so far. How does this work? Can I do it programmatically or so perhaps? I hope someone can straighten out this question mark...
A container view is intended to represent an area that will host a view from a different view controller that becomes a child of the view controller that owns the container. Usually, you would create a second view controller, link your container view to it using an "embed" segue, and then put your buttons and such in the second controller's view. The code behind those would then go into the second controller.
If your purpose is simply to have superviews to control layout within a single view controller, use a UIView rather than a container and the problem goes away. That's what the Editor->Embed In->View menu item is for.

Showing views in interface builder outside viewcontroller hierarchy in xcode5

I often make use of views in interface builder that live outside of the viewcontroller hierarchy (see screen grab below for simple example).
Before upgrading to Xcode5 I could get this view to appear on the storyboard by writing an IBAction outlet and dragging a connection from the code to the view in the storyboard.
If you paused over the button for a moment it would flash and then open up as a view on the storyboard that is then a lot easier to work with.
Since upgrading this function no longer seems available. Has anyone found out how to get these views to appear on the storyboard?
Edit:
Using the temporary viewcontroller as described in this answer seems one approach, although fiddly since you need to move the UIView stack between viewcontrollers each time you want to edit the layout. Using a separate XIB is starting to seem like the sanest approach.
https://stackoverflow.com/a/13713385/1060154
Finally, we get this back in Xcode 7.
Hallelu!

XCode, Storyboard, View Controller items are not being displayed

When opening up a project today, there is some weird behavior in XCode. Things have disappeared in the storyboard view like the NavigationBar in viewController, the buttons associated with it, etc. I can see in the Scene list that they still exist. Is there any way to have these show up again?
You probably need to add a navigation controller to your storyboard and make your view controller the root. You cannot simply set the top bar in simulated metrics in storyboard to navigation bar.

Resources