Is it possible to comment on storyboards? - ios

So I've been using Xcode 7's new feature to reference storyboards within storyboards. To add clarity to my references, I want to add a comment of sorts that can explain exactly why I've split up my storyboards.
Does this feature exist? I know I can create some dummy views but I feel like this is lazy and a bit inefficient.

In you identity inspector there is a place you can write notes, that's basically your comment section.
Select your storyboard Object
Click show the identity inspector.
Then write your comment in the document note section.

This is a good way of commenting visually on a storyboard, but still isn't perfect and is still a dummy view. I find it is probably the cleanest way to do it right now.
Add a Storyboard Reference to your storyboard
Navigate to the Identity Inspector on the Storyboard Reference you added
Set the Label attribute to your desired comment
You can now move the your comment wherever you want inside the storyboard

You can place comments inside the source code of the storyboard. Since .storyboard files are XML-based, you can write standard XML comments in it:
<!-- This is a comment -->
To open a storyboard as source code, right-click on the file in the Project navigator (the first icon from the left on the right sidebar) and select Open As/Source Code:
To return to Interface Builder, select Open As/Interface Builder - Storyboard from the same contextual menu.
WARNING: Always place these comments after the first line of the file, since Xcode expects an XML declaration there.

Related

create a strings file for a custom storyboard

I am localizing my app, and I have a custom storyboard I created called Into.storyboard. When I added a language to the app, it gave me an option to create strings files for Main.storyboard and LaunchScreen.storyboard, but not for my custom storyboard. How do I create one so that it automatically fills in the object IDs like it did for the other two storyboards? Thank you
At the right side inspector you can find button localize. Press it and choose languages.
Example

Replacing Swift Storyboard with New, Imported Storyboard

Having completed the functionality in code, my app required a full redevelopment of the original interface design. That was done by another team member, in a separate project.
It seems obvious that importing the new design as a storyboard file and using that is the next step. The original storyboard has a number of segues, I'd like to just replace the UI contents of that with the contents of the new storyboard (and then reconnect everything).
I'm not sure how to do this. What's the best method?

How to add items to an Outlet Collection in Xcode

I am creating a quiz app and for the buttons I need an outlet collection. So far in the array, I only have one button but I want to add the other three. On the other tutorial I've watched, it says to click the button on the side and drag to the thing you want to add (image link below). This doesn't work for me, is there a certain way you need to click? I've done this before, but this time its not working. The difference this time is that I've created a new class. I am not very familiar with Xcode or swift, sorry. Thank you.
Xcode is really buggy as far as outlet connections are concerned. Emptying the Derived Data folder as well as clean / rebuild help. But results could still be problematic. However, the old way to connect things which has been around since before the existence of an Assistant editor still works reliably. Select the ViewController and drag from ITS outlets in the Connection editor to the storyboard items (i.e. buttons).
Use Interface Builder alone. Use the Identity inspector to make sure your view controller has the correct class, the class where you put your outlet collection property. Now use the Connections inspector for your view controller. You'll see the outlet collection listed there; drag from it to your buttons, one by one.

Copy & Paste items from one view to another within storyboard without referencing outlets?

When I copy and paste, (cmd-c, cmd-v) items from one view to another in Storyboard it also copies and pastes the items referencing outlets.
Obviously, it's achievable by going in and deleting the referencing outlets one by one. Which is what I want to avoid.
I'm looking for something akin to (dare I say it) Excel's 'paste special' command.
UPDATE
Nope, doesn't work in xcode 5.1 either, see image below, hopefully it succinctly shows you what is going on.
The image shows a view at the top, Add Expense View Controller, another view at the bottom, the name's beside the point, I've copied my cells from Add Expense View Controller, lo & behold it's got the old references in there. You can also see I'm using xcode 5.1...
So - how do you, or is it simply not possible, copy and paste without these references?
Interestingly there is a paste special option in the Edit menu, but in Xcode's menu definitions in the documentation there is no definition for "Paste Special"...
Seems like they fixed it on Xcode 5.1. Both copy/paste and option+drag doesn't copy the referencing outlets.

how to remove all references for outlet

I accidently set event for command button as "outlet" than "action". Due to auto-drag feature, xcode generated references in applicationDelegate and .h and .m files. I removed the entry from .h and .m files but simulator wont run because it is still looking for that missing reference. I could not find that outlet referred anywhere. I am fairly new to iOS programming. Can anyone suggest a solution for this?
You have to unlink the outlet from the item in interface builder. Select the UI element that you linked the outlet to and then remove it in the "Connections Inspector".
Click the little "x" ^^^
I think there are two different reasons that people may come here wondering how to get rid of an unwanted Outlet reference.
Created an unwanted outlet while using the Interface Builder.
Copied some Outlet code from another projects View Controller.
Both reasons are fairly easy to solve.
Unwanted Outlet in IB
Method One
Right click the view in the storyboard and then click the little x by the referencing outlet.
Method Two
Right click the view name in the Document Outline. Then click the little x by the referencing outlet.
Method Three
Select the view on the storyboard and then click the Connections Inspector. Then you can click the little x to remove an outlet reference.
Unwanted Reference in Code
If you copy the view controller code from one project into another project you will notice a strange thing happening with the outlet. It is referencing the view from the first project without you ever connecting any outlets!
If you left click the little circle and click the reference link you will even be taken to the storyboard view in the other project. Trying to figure out how to get rid of this reference can drive you crazy.
Well, the good news is that there is really nothing for you to fix. You didn't copy over some deep, hard to find referencing link. Xcode is just getting confused because the View Controller and the outlet name are the same in both projects. Basically just ignore what that little circle says. You can close the first project and Xcode will figure things out eventually. Use the methods in part one of this answer to see if a view in your current project has a referencing outlet or not.
No need to delete Derived Data. That doesn't solve the problem anyway. Just try opening both projects at the same time again and you will get the same strange behavior. The way I figured this out was to separately create two new projects that had view controllers with the same name and a referencing outlet with the same name. I never copied anything but Xcode showed one was referencing the other. Like I said, ignore it.
It will be listed in the storyboard/xib as well, on the command button outlets.
Delete it from there as well, and you should be good.

Resources