Storyboard is very slow - ios

So I've been working on a project for a while that has so many view controllers, but I notice that now when I try to do a single edit in any view , storyboard hangs, or become unresponsive . what would be the solution for this issue ? is it possible at my current state to split up the whole storyboard into smaller ones ? and will that resolve the problem ? I'm using Xcode 9.3

Yes. You can have more than one storyboards in one project. In fact that's the preferred way to manage very large projects. To create more storyboards go to File Menu > New > File... and then select Storyboard from the User Interface section. Doing this should resolve your issue. However, if the issue still persist you can consider taking out the specific user interface into its own .xib file.
Update:
If I were in your position I would have considered using .xib files to create my user interface instead of using storyboards. Storyboards do have their advantages but there are some cons too if you use them. Like:
If you work in a team you will run into merge conflicts more often because someone else made a change in the storyboard.
I am still not a Guru in S/W design but, to me it seems like Storyboards violate the Single Responsibility Principle of S/W design.
You won't be using Segues in complex ui flows anyways so what's the point of having every thing in one file.
You won't be able to reuse your UITableViewCells interface. Prototype Cells are a good idea but if you have a UITableViewCell which is used in more than one UITableView you will have to replicate the UI in Storyboard.
In my experience, in a more complex and large project having everything in one Storyboard makes it even hard to comprehend the UI/UX flows as Segues from every view controller seem to connect with every other view controller to the point where it just stops making sense at all.

Yes, it is best practise to distribute viewConrollers into multiple storyboards so that you can open it quickly but it can lead your time to manage each storyboard identification programatically while accessing into code.
Otherwise, you can set storyboard View as : iPhone 5C so that it can load little bit faster than bigger devices.
Refer:

Related

Use storyboard or xib for single view controller?

I have to implement the layout of a single screen, which is not connected to the overall app flow, and I was wondering if it makes sense to use a Storyboard.
Storyboards make sense for flow/navigation (multiple controller), have some convenient features like, iirc prototype cells which are not available in xib. And it also makes sense if I think maybe later the screen may become a "story" (more view controllers). But none of this advantages are useful for my particular case.
I was thinking anyways in using Storyboard, as it seems to be a bit more flexible than xib generally, but is there any disadvantage? Maybe performance penalty or such? Is there a preferred way to setup single view controller?
Go ahead..take the advantages of using storyboard. There is no disadvantages or performance issues particular to storyboards when compared to xib files. Its all about your convenience. As you said the single view controller may become a story in future, then the storyboard would be a right decision. And when to use xib? thats upto you, one ideal situation where i will choose xib is, if i have an independent controller that i want to share with other project also then i would choose xib.
The performance penalty would only bother under the circumstance which too many controllers (more than 10) with segues were squeezed in one Storyboard. Everything would be totally fine before that.
And if you have more than two people are trying to edit same storyboard file than you have to resolve conflict, which will be more tedious job.
Storyboard benefits:
a. easy demo purpose and fast implementation.
b. small team like two person.
c. Storyboard is providing complete view and navigation model.
XIB benefits:
a. You can modularize your code.
b. More people can work on different-different controller without affecting your xib or code.

Single Storyboard vs Multiple Stoaryboard in XCode, which one is better

Is Multiple Storyboard in single project is better than single storyboard??if yes then why??
Which is better Single Storyboard or Multiple Storyboard??
Any one please clear me the above queries.
It depends on the project requirement. If you are good enough with the size classes and auto-layout and also if the requirement flow is almost similar for all the devices then go with single storyboard.
By default in Xcode 6 or later, recommending to use single storyBoard.
If you have a bigger app and/or not only one man team:
You should NOT use single story board. Like its name says, it is a "STORY" board. You should have one Story in one Board. This keeps the readability and maintainability of the storyboard.
If you have a team, it is a nightmare to "merge" one single story board if 2 made changes in it at the same time. It is more or less impossible. But if you have for each story a corresponding storyboard, even in a scrum team you can manage to work on one storyboard only one person, that you do not need merging.
There are a lot usefull documents and workshops in internet if you google "ios storyboard git merge ...."
When to Use Storyboards
Finally, while Storyboards are best used for scenarios involving multiple view controllers, it’s also defensible to use a Storyboard when working with a single table view controller for three reasons:
The ability to design table cell prototypes in-place helps keep the pieces together.
Multiple cell templates can be designed inside the parent table view controller.
It’s possible to create static table views (a long awaited addition that’s unfortunately only available in Storyboards).
When Not to Use iOS Storyboards
A few cases:
The view has a complicated or dynamic layout, best-implemented with code.
The view is already implemented with NIBs or code.
When to Use NIBs for iOS UI Design
A subset of all uses cases would be:
Modal views
Simple login and registration views
Settings
Popup windows
Reusable view templates
Reusable table cell templates
Meanwhile…
When Not to Use NIBs
You should avoid using NIBs for:
Views with dynamic content, where the layout changes significantly depending on content.
Views that by nature are not easily designable in the Interface Builder.
View controllers with complicated transitions that could be simplified with Storyboarding.
Apple's docs say that you may have multiple storyboards. Unfortunately they don't go into any real detail on how to do that. As you've found out, Interface Builder won't help you, so you'll have to do it in code. It works much like loading XIBs:
[UIStoryboard storyboardWithName:#”MyNewStoryboard” bundle:myBundle]
Having said that, if you don't "want one big/bloated storyboard" as then XIBs really are the way to go. That 'bigness' is the benefit: all the transitions between VCs are laid out in one place. Having multiple storyboards is really so that you can support multiple different and unrelated flows through your app: for example, one storyboard for a complex configuration flow and another one for the main user flow.

Show/Hide UI elements in a storyboard depending on the target

I have read a lot about creating a lite and a paid version with Xcode and in my app I am using multiple targets and preprocessor macros as described in this Stackoverflow post. However, I don't know how to handle different targets with a Storyboard.
For example, in my storyboard I have a table view controller with static cells. In the paid version it has four cells, in the lite version has one extra cell whereas the rest of the storyboard remains unchanged. Is there a way to achieve that kind of behavior?
(Creating a new storyboard for the lite version (or duplicating it) is not an option for me as I have dozens of view controllers and 98% of the views and UI elements are identical in both versions. It would make the project difficult to maintain.)
For example, in my storyboard I have a table view controller with static cells. In the paid version it has four cells, in the lite version has one extra cell whereas the rest of the storyboard remains unchanged. Is there a way to achieve that kind of behavior?
If you hadn't boxed yourself in by using a static table, this problem wouldn't have arisen in the first place; you'd be configuring the table in code, which can be conditional — end of issue.
As things stand, you'll need two different scenes in the storyboard, one for the paid version, the other for the lite version. Then:
If this scene is reached by a segue, you'll need two different segues that reach this scene, and you'll decide in code which one to trigger (and trigger it in code, not automatically).
If this scene is the initial view controller, you'll need to instantiate it initially in code rather than letting UIApplicationMain do this for you. Or, in that case, use two different storyboards for just this one scene, and then segue to another storyboard.
(And do keep in mind that multiple storyboards are a great way to organize your scenes in any case. I don't necessarily mean multiple alternative storyboards; multiple sequential storyboards can keep your storyboard from becoming overly complex. It sounds to me from your question as if all you need to do is understand how storyboards work - they are not magic, you know - and be more nimble in your use of them. Your entire deer-in-the-headlights fear of duplicating your storyboard - "I have dozens of view controllers" - suggests you've already gone way too far down the wrong road. Programming is like solving a Rubik's Cube: if you're in the middle of it and your response to someone trying to change something is "don't touch it!", you're doing it wrong.)

Which is more efficient way? StoryBoard or XIB?

My question is slightly different then my title suggest.
I have worked with xib. Now i am trying to work with storyboard.
My question is if we are navigate through one class from another class, is StoryBoard giving benefit for better memory management.
Suppose we have 2 ViewControllers: ViewControllerA and ViewControllerB.
We are trying to go through ViewControllerA --> ViewControllerB.
Now, in Xib our approach is below;
ViewControllerB *VCB = [ [ViewControllerB alloc] init];
[self.navigationController pushViewController: VCB Animated: YES];
Where in Story Board,
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"Second"])
{
SecondViewController *objSecond = (SecondViewController*)[segue destinationViewController];
}
}
And Do,
[self performSegueWithIdentifier:#"Second" sender:self];
So, My question is We alloc our class in Xib, Where in storyBoard we aren't.
So is there any memory allocation advantages in storyboard?
My point of view that a professional developer MUST use xibs, but a hobbyist, new to programming, developer might be helped if he uses storyboard.
Storyboard
After a 3 year project work with a single storyboard I can tell a lot of disadvantages:
1) It REALLY gets VERY VERY slow to build even for a very very very little think ( every single view in it must be rebuild ). Also it is very hard to edit even with an iMac with 8 or 16 gb ram if the Storyboard gets bigger. It's even hard to open it.
2) No reusability. There is no way you can import immediately a View/ViewController with its view to another project. It will be connected with other ViewControllers, Views Or Segues and that will make it like a big "don't touch" think.
3) there is so much lag when the project gets bigger even for the smallest layout constraint to be added or edited, that you never want to touch it.
4) If you use the cells by automatic cell addition of storyboard, you cannot use the same cell build in two points.
Advantage:
1) Automatic Cells (But this is also a disadvantage because a cell cannot be reused as is to another view)
2) Segues etc would make it easy for someone to understand with a single point of view what is happening.
Xibs:
1) Fully portable.
2) Open/Edit/Build SO MUCH MUCH MUCH faster than a storyboard that gets bigger
conclusion:
If you are a hobbyist developer who will make an app for his business for fun, you should use storyboard because it will it easier to understand things.
BUT, if you a professional developer, you MUST use xibs for VCs, Cells, etc, Because this is the only way to make them really reusable and portable, in order to gain so much time for the next project, or even when having to make a little change or build the storyboard again.
Explanation why xibs are more "reusable and portable" for me:
Things in programming must be kept in different models, files, entities, modules. One must be as least dependent on another thing as it can get
It is not to tell which one is the best. because which one is good to tell based on team requirement.
If you are a single developer, it is good to use storyboard because it consumes less time. If the team consists of many developers, use xib, otherwise, it is not easy to merge the modules/tasks.
xcode-using-storyboards-and-xibs-versus-creating-views-programmatically
Using XIBs
Advantages:
You can quickly put together a UI
Straight-forward implementation for small apps with a minimal number of screens
You can have separate XIBs for different localizations (ie. languages or countries)
Great at laying out elements and visually spotting misalignments. It’s easy to make a slight adjustment to the layout
Disadvantages:
It’s difficult to merge conflicts when working in a team environment (hard to diff, merge and read)
Highly dynamic views are impossible to describe as a XIB
Performance wise, it’s slower than creating views through code because the xib needs to be read from the disk and analysed/parsed
XIBs lack customizations that you can do in code such as Quartz stuff (drop shadows, round corners)
Harder to debug (i.e. if you forget to make a connection in Interface Builder or make a wrong connection)
Storyboards
Advantages:
Storyboards are nice for apps with a small to medium amount of screens and the requirements for navigation is relatively straightforward between views
You can mock up the flow of an application without writing much, if any, code
Disadvantages:
Storyboards are not compatible with pre-iOS 5 so it makes supporting iOS 4.3 impossible
It’s hard to work in parallel in a team environment because everyone’s modifying the same file
Along the same lines, merging conflicted storyboards in GIT will be a pain
People have experienced bugs in Xcode with the usage of storyboards (eg. having to frequently flush the DerivedData folder because of inconsistencies)
Comparing XIB and storyBoard, StoryBoard is fast.
But Actually fast when do the whole project in programatically.
in storyboard when we compile all storyBoard is Archive to file. and unArchive then run the application.
But, in programatically Classes are allocated at the run time only.
Recommended do project using storyboard.
story board is highly recommended from apple engineers now and highly recommended every thing is central and memory management is done by compiler. how ever pushing a controller is requested by designer in some case and have no issues. but storyboard is recommended and easy to understand view part of MVC
Using Storyboard would be a better option as far as memory utilisation is concerned although storyboards have other advantages also over xib files, Apple also recommends using storyboard over xib files.

How to manage the development of storyboard when several people edit the storyboard?

All of our views are in a single storyboard. After we edit the interfaces we are responsible for, we find it is a disaster when we commit the storyboard. Do any better ways exist that make it easier to manage the storyBoard? Should we write UI with code instead of storyboard or xib? While it is really efficient to use storyboard.
What's generally worked for me and my team is to separate related functionality into different storyboards. So if one person is working on x portion of the app, stick all things x related there. As long as only one person is dealing with each component at a time, there's no chance for conflicts that blow up your whole storyboard.
Another thing to keep in mind if you can only use one storyboard, is to limit who can work on each ViewController in the storyboard. It's not the best idea to have multiple people working on the same controller anyways, since you will both be interfering with each others layout. I have found that as long as we stick to our own components, merges are super easy.
Your solution of using code instead of storyboard is also a very valid way to go about it. The decision between code and xib based approaches depends on the user. Code takes longer to get going, but is super easy to reuse, whereas xibs/storyboards make prototyping a snap but are very hard to reuse.
You need to read this links:
http://blog.waynehartman.com/archive/2012/01/07/uistoryboard-on-ios-5-the-good-the-bad-and-the.aspx
http://www.linkedin.com/groups/Which-is-better-StoryBoard-NIB-162305.S.185584395
Should I use storyboard and mercurial for team work?
Storyboard is one single file, so only one person can work on the storyboard at once. It is essential factor for working with team in iOS.
The following post helped me to understand answer on this question:
http://robsprogramknowledge.blogspot.pt/2012/01/uistoryboard-best-practices.html

Resources