iOS - from code to storyBoard - ios

can i generate automatically storyBoard from existing code?
If not, does someone know a good way to make the connection between the current code and new storyBoard?
Thanks in advance!!

can i generate automatically storyBoard from existing code?
No, you can't.
You will have to analyze what the code does, and translate it into the new storyboard. Or you can simply use XIB files, this way different persons can tackle different parts of the application, without risking too many conflicts when committing the code.

Add a new Storyboard to you project like the pic below :
and then set its target from Summary -> iPhone/iPodDeployment Info :
However this is just to make a new MainStoryBoard for your app.

Related

Xcode with multiple projects Storyboard reference bundle not working

I'm having a difficult time trying to figuring out how to make a storyboard reference work with storyboard from other project. I'm trying to modularize my App, so I'm creating multiple projects inside Xcode workspace. The point is that at some times, one storyboard from project A may have a reference to a storyboard in project B... I thought that the reason for the 'BUNDLE' option in a storyboard reference is that you could achieve what I've mentioned... I've attached an image that explain better what I'm saying... When I try to run, the app links to the Main.storyboard from Project A instead Main.storyboard from Project B...
I've checked and rechecked to make sure that bundle name is correct...
Thanks a lot, guys.
First give an id to the reference screen.
second write the storyboard referans add Reference id
The bundle name in the StoryBoard reference is the bundle identifier of the FrameWork/Project that contain your reference story board. For example: com.chozinul.CustomUI
Use storyboard name and push controller will viewcontroller identifiers

Xcode jump from viewcontroller.swift to storyboard

I'm working on a large ios app and I'm also a newb. I'm trying to find the correct scene in a storyboard in a large app. I'm in the .swift file and I need a quick way to figure out which scene is associated with that swift controller file. The only way I know now is to go through each scene and look at the Class property, which will take forever. Is there a shortcut to jump from the swift file to the associated scene?
In Xcode, open "Find in Workspace..." (Command+Shift+F)
Type the name of your ViewController.
In the results panel, check the entries under the .storyboard file. Clicking on them will open that exactly scene in the Interface Builder.
Profit.
You can also go further and filter the search by filetype. Check this out:
Create a custom Scope:
Super awesome result:

The document "Main.storyboard" could not be be opened

I'm using Git and we are 2 people coding together. I pulled my friend's code, run it and it worked as it should be. Then I merged our parts and cleaned conflicts (almost all of them were in storyboard). Since i'm doing this merge process for a while, i'm not all stranger for these details.
However, when i run the merged version of code, i get the error:
The document "Main.storyboard" could not be opened. The operation
couldn’t be completed. (com.apple.InterfaceBuilder error -1.)
I can't open storyboard as interface builder either. When i try it, I get the same error. I read previous post about this error but as I mentioned, I can open and run both versions of code in my XCode before merge. Thus, there is not a font or attributed string problem.
What may be the problem?
I got this issue, after I solve the conflicts which is merged by svn.
I could only see the source code of my storyboard, I could not open my storyboard as interface builder. So, after my struggle,
1)I delete the topside space line in my storyboard source code
2)and close my Xcode and simulator
3)restart my project
it becomes regular, oops, the space line on the source code will affect our storyboard !
there are conflicts in Storyboard. You can take last working code of storyboard from github. select storyboard select version editor and copy last working storyboard and replace xml with existing xml.
I guess your storyboard still have confliction.View your storyborad as source code, then fix all conflictions. After all, open it again as Interface builder
For me the only thing that worked was to create a new storyboard file, open the old and the new storyboards as source code, and copy the xml from the old to the new storyboard. I didn't take the whole xml, just the scope of the <scenes> </scenes>
I had to create a new Storyboard file. Then cut and paste the "scenes" tags from the old and put into the new. I then had to delete the old Storyboard from the project in order for the project to build successfully!
I guess the problem is that storyboards don't merge very well, I think it is better to init your UI from code so there will be no troubles during merges. Anyway you should try to rollback and merge it again.
As other mentioned, there are likely merge conflicts in the storyboard file.
If you can't easily solve the conflict by either picking --ours or --theirs, you will have to perform the merge manually in the storyboard file.
What I do is open in in a text editor (e.g., TextEdit.app - but make sure it opens documents as plain text, in Preferences).
Then, locate any occurrence of the git conflict markers (or a portion thereof, e.g., "<<<<<"), and pick the code fragment that you want to leave (and remove the other, of course).
EDIT: As Cong Tran mentioned (and I forgot), you can open storyboards as source code from within Xcode itself (see his answer).
Fast way to fix
Copy the storyboard Id shown on the error prompt window
Right click on your storyboard
Choose Open as => Source Code
Search the id and delete one of the duplicateID and you are done!
i would suggest , right click on any of the files and click on finder then you will have what you need and drag and drop

IOS: multiple language xcode 5 for launch image

I have a problem, what's the way to organize localized launch images in xcode 5, is there a way to do it?
thanks
SOLVED!!!!
Set in plist file "Launch image" in "Default"
and have two file for launch image in the project as
Default-Landscape#2x~ipad and Default-Landscape#~ipad
that you can localize as another file...
Yes, you have a way to do that. Looks like you can get an idea to your answer here in this post of StackOverflow Question.
Please do check the answer posted here. That is more close to your question.
Actually, you can create a temp ViewController and you can put a UIImageView on your View. After launch your program you can direct to this temp ViewController and set the image according to your language. than you can call your main ViewController.
And i used this class for change the language in my program.
https://github.com/tonisalae/TSLanguageManager
I hope, it can be help for you.

renaming .xib file in Xcode 4.3.3 is this the right way?

I wanted to rename the files .h, .m. .xib into my own name.
I have created a tabbed application, and I did single click on the source browser, and changed
FirstViewController.h to FVC.h
FirstViewController.m to FVC.m
and changed respective places to include FVC.h.
It works for me. But what i would like to know is that is this the right approach that i can go ahead with?.. will there be any hidden issues with this approach?
The only "gotcha" is that if you are using the nibName in your code (ie initWithNibName:), you obviously need to change that too. I personally have gotten bit with that problem - the app launches then crashes when it tries to push that broken object.

Resources