Ok,
I'm very confused about something... being new to development on iOS I'm often pushed towards the storyboard/graphical design (specially to make file owner, segue, etc type of connections). HOWEVER; every time there's something besides a basic (dare I say primitive) design, I have to do things via code... problem is that just because you can do something via code doesn't make it right according to Apple. so you have to know all the rules to have you app approved. Even some of the examples from Apple (UISPLITVIEW with multiple view controllers -> MultipleDetailViews) do not have story boards just XIB... is that normal???
So question is: why have graphical design if you have to move towards coded solutions anyway. just to say that you have an easy to program interface?
can anyone help me understand that??
cheers!!
Three things (at least!) are going on here:
Storyboards are relatively new and a lot of examples existed before storyboards were introduced.
People are always dreaming up things that are more complex than a very high-level approach can handle. (Even with .xib files, which are more flexible than storyboards, people write custom code to get around limitations.)
For examples, code is linear and a bit easier to follow than the description of a bunch of clicks and drags.
So, first of all, a storyboard is nothing more than a conglomerate of .xib files. When you use storyboards, Xcode handles unloading all the nibs for you. At its core, your app still uses these nib files.
Additionally, your app won't get rejected if you use code to set a property instead of setting it in Interface Builder, or vice versa. I don't know that I would say Apple's stance is just because you can do something in code doesn't make it right. I would argue that they urge developers to set as many properties via IB because less code that you write means less bugs that you introduce. If I have a view in a nib, and I check its "hidden" property in IB, that's no different than me saying view.hidden = YES in code. Apple doesn't prefer one over the other. But using IB relieves me from having to know that the property to hide a view is "hidden" and that it accepts a BOOL as an argument. If in iOS6 they decide to make it shouldHideSelf, using IB's hidden property will be automatically updated, where as I would have to manually update my programmatic setting of the hidden property.
Related
This question already has answers here:
Adding Views. Storyboard VS. Programmatically [closed]
(2 answers)
Closed 6 years ago.
Is it more efficient to add views and subviews programmatically than using a storyboard to add them ?
What is be the best practice ? Does the best practice depend on the situation ? If so, when is it preferable to use the one method over the other ?
Storyboard vs Code comes up an awful lot. And I think looking at it as which is better often starts flame wars. So instead I'll list out pros and cons for each, then you can hopefully make an informed decision.
This is by no means an exhaustive list. I'd love to see edits or comments adding additional bullet points.
Storyboard Pros
Storyboards are great for getting a concept working quickly.
They're great for seeing your actual app and previewing it on multiple devices.
They make it really easy to customize appearances and explore whats possible.
They're fantastic for beginners as they remove one barrier and let you focus on code for your app rather than some boiler plate UI.
Storyboard Cons
Storyboards and Xibs are not great for merging. Its possible to read the XML and make decisions about merge conflicts, but its certainly not enjoyable.
Overtime as you customize your app and build the custom parts that make it special, Storyboards can't keep up. This means that the benefit of seeing and previewing your app as you see it on device slowly loses its value as more and more of your app is done in code out of necessity.
Storyboards don't have a huge performance hit for actual users, but they definitely slow Xcode down on even the fastest machines.
You can't customize everything in Interface Builder that you can in code, so its inevitable you'll have some code and some Storyboard customization. Later when you want to change something, you'll have to check at least two places for the right place to change it.
If you're using the same fonts and colors throughout the app, its easy to change in code in one place. In Storyboard you'll need to change it for every single label or view you've set up. You can easily set fonts and colors in code while using Storyboard for the rest of your layout, but over time you'll find your storyboards represent less and less of your actual app.
While its possible to have pixel perfect designs in Storyboard, drag and drop isn't as precise as entering specific numbers. Storyboard does support entering those numbers, but you need to navigate to multiple places and if you drag it later the numbers are all reset.
Reusing views typically involves copy and pasting them. These causes issues later when you need to make changes.
Showing and hiding views at certain times is doable, but again leaves your storyboard in an unrealistic state compared to your actual app.
Programmatic Pros
All your code is in one place making it easier to debug or change later.
Subclasses and custom properties are no different from first class views and properties. Your customizations will be easy to manage.
Views that are reused throughout the app only need to be created once.
Merge conflicts are often easy to understand and make decisions.
Dependency Injection is one of the safest ways to instantiate UIViewControllers and ensure necessary information is passed in, its not possible with Storyboards leading to less straight forward and more bug prone code.
Programmatic Cons
The additional complexity can be a stumbling block for beginners.
Writing a few lines of code can take longer than clicking a few checkboxes.
When working with layouts, you'll need to visualize it in your head or run your app to see what your layout looks like as you make changes. This can be difficult or slower for some.
Storyboard exposes checkboxes and buttons for many customizable properties like background color, font, etc. This makes it easy to see at a glance what you can customize. (Though as mentioned above its not everything) In Code, you'll need to look at documentation or headers to understand what you can customize.
I am curious to know if anyone has any experience comparing the load time performance of iPhone apps with views laid out in NIBs vs. views laid out entirely programmatically (here is a similar question).
Is there really any advantage of views laid out entirely programmatically over views laid out in NIB ?
According to Apple, XIB file loading time is longer than build UI programmatically.
Saw that in a WWDC lecture.
If performance is what counts, build your UI in code and not in IB.
There are some advantages by doing it on code:
Better to work with several people. It's easier to resolve conflicts when committing to a repository.
You rely on what you see on the code, and not in something hidden in the nib file (some pesky option you select without being aware). You have: what you see is what you get.
With nib:
I would say it's faster to develop.
The code it's not so "polluted" with every single detail about your interface.
I also would stay it's easier for people who don't have a lot of experience.
About performance, you can actually check this.
When I was beginning to learn iOS programming, I was building UI in xib file. But when I had developed some projects, I began to just write code to implement my UI.
There are some benefit through building UI programmatically:
First, by writing code, you have the view hierarchy clearly in you mind, and the view hierarchy can be important to efficiently implement your UI.
Second, if your UI is complicated, for example, with some animation or transform, you will benefit quite a lot from coding UI. Even sometimes you may not use UIView to build UI, you may use CALayer to accomplish some effect, which can not built by xib file.
Furthermore, when you get used to building UI programmatically, you will love it, because you can just code in the .m file and has no need to worry about the xib file.
However, if you are just a beginner in iOS programming, just fine to get start with xib file.
(Apple now provide StoryBoard, I have not learned about it, you may learn it to find if there is anything new.)
IMO a mix of both would be the right choice. Using interface builder for defining the basic layout (i.e a xib that doesn't change much over time) and default options of views and for the rest can be done programmatically (specific tweaks and effects). This should solve the source control and performance problems to some extend.
Although once we start off creating views programmatically ,we continue doing it for every time not realizing that the same thing could be done with much less effort in Interface Builder. After all if it's a GUI we are building it's better to have a visual reference.
I am new to iOS and was wondering which is the best to learn. I have read some of the answers here and SO, but some people say use Storyboards will others say learn XIBs first. Is there any real benefit to learning XIBs? Are XIBs easier to understand and will help with storyboards?
There is benefit to learning both approaches.
Apart from the historical value in the xib approach, xib's also provide modularity. Perhaps you have a library of code or wish to share a useful widget you made. Taking the xib approach would facilitate that sharing and reuse.
The xib approach also allows you some greater flexibility in terms of your own code. For example, iOS 5 contained a bug with UITableView and Accessibility/VoiceOver support that would cause -dequeueReusableCellWithIdentifier: to return nil despite being documented otherwise (see this blog post for further details). To dynamically load table view cells from xib provided the ability to work around the bug.
While the table and tablecell support in Storyboards is wonderful and provides support for what most people need to do in a table, sometimes you have to color outside the lines, you might need lots of different cells, and again, dynamically loading from xibs can be your solution.
One big advantage of Storyboard is the ability to view your entire application's GUI flow. Zoom out and you can see how everything interconnects and flows. With xibs, while the modularity is nice, it's tougher to envision how everything connects and flows together. This can be a useful feature for yourself, or if you have a larger team to share with, to allow others to see how the app flows.
There's value in both approaches, and it's good to know both so you can pick the best tool for your task at hand.
Update 2014-10-06 - Since I wrote the above, I've been involved in more projects. Some with xib, some that could use storyboards.
Storyboards have matured a great deal (we're at Xcode 6 now), and there's a great deal with them that's so nice. I really love how so much more can be done within a storyboard that is a bit more complicated in a xib-approach. A couple examples:
One is when working with UITableView or UICollectionView how much you can work with prototype cells directly in the storyboard. A lot of nice and easy setup, most of the heavy lifting can be in the storyboard, less code. It's quite nice. Trying to do this in the xib approach is certainly do-able, but there's a lot more work to make it happen.
Another is how nicely you can transition between UIViewControllers with the regular segues then go back with unwind segues. All right there in the storyboard, with minimal code. It's just so handy.
But the one thing that still kills storyboards for me is trying to use them in collaborative environments. It's just not going to merge well. And in some regard, it's not even if you're working on a team of > 1 person. If you yourself take advantage of version control, use a good branching and merging model for your own personal workflow, there may come a time where some change is going to have to be made in some branch that has to be brought into another branch, and oh the pain. To me, this is what kills storyboards.
As time and work has evolved, what I'm finding for myself is storyboards are great for prototyping. The ability to get things going quickly is a huge benefit of storyboards. There's much speed in using them. But the speed comes at cost. When it comes to writing the "real" code for some project, I'm just going to stick with xibs because while it may be more work, it's a more flexible route that just works better in larger teams or over time.
Update 2015-04-07 Another update, because the projects of the past some months have forced me to use storyboards, which has provided more insights.
First, some things will mandate one approach or another. For example, apparently there were some edge case bugs when working with size classes in xibs that didn't exist doing the same thing in a storyboard. So if you get affected by bugs, that may force your hand one way or the other. Another is to remember that storyboards generally work on the UIViewController level, so if you need to do something like have a UIView or a UICollectionViewCell to load, that's probably going to be better served by a xib.
Second, and I don't know why this didn't occur to me at first, but there is nothing that requires you to use a singular storyboard for your entire project! I think the nature of storyboard enables people to gravitate that way, but we have to remember nothing mandates that (that I'm aware of).
What I've found works well is to generally approach each "view grouping" per storyboard. That is, often your ViewControllers tend to be isolated and wind up being 1 per storyboard (or xib). But you might have a situation where you have two closely-related ViewControllers, and it makes sense to put them into the same storyboard, especially because then you can easily hook things up between them, such as segues.
The main advantage to multiple storyboards? Working in teams. This way Fred can work on his storyboard and Wilma can work on her storyboard, and there's no strong worries of merge problems or work coordinatinon! The use of multiple storyboards (and generally 1 ViewController per storyboard) has been a huge help in the use of storyboards on a multi-person dev team.
It's pretty evident Apple wants us to prefer storyboards, and I'm embracing them more these days. Using multiple storyboards, but still using a xib when needed, is working fairly well now.
Update 2015-09-21 Now that Apple's released Xcode 7, there's even more reason to adopt storyboards, as Apple works to overcome the shortcomings.
The most important improvement is storyboard references, which allow you to create in one storyboard a reference to another storyboard. It's dead simple to make, and now you can have cross-storyboard segues (both entrance and exit). I've used this a few times already on a new project and it's just a joy.
Another improvement is that you can create stand-alone UIView classes within a storyboard. However, as of this writing I've had mixed results with it. Simple cases work out ok, but some more "complicated" stuff did not. For example, I had a UIViewController with a UITableView within it. Since it was to be a simple table with 5 static cells, I merely instantiated the 5 UITableViewCells as a part of the ViewController in the storyboard. Seemed to work, but then at runtime nothing would actually load and show up; moved the UITableViewCells into a xib, and all worked. I'm not sure if I was doing something wrong or what it may be, so YMMV. But still, even if there's just some quirks, in time I'm sure Apple will resolve them and then another barrier against storyboards will fall. I would say that if you need such support, you should try it and see how it goes for you. There's great promise.
More and more, storyboards are shaping up to be excellent.
There are things you can do with a storyboard that you can't do with a nib. A storyboard lets you create segues between view controllers, and it lets you design table view cells in-place.
There are things you can do with a nib that you can't do with a storyboard. In a nib, you can create references to the File's Owner placeholder. You can create multiple top-level views, edit them, and create connections between them. See this answer for an example of why you'd want to do that. You can add external object placeholders (a rarely-used feature).
Storyboards have the drawback that they collect a bunch of different, loosely-related objects into one big file. If you're working on a project with several developers, you are much more likely to run into merge conflicts if you're using a storyboard than if you're using xib files.
You should definitely learn about nibs at some point. Whether you want to start with them or start with a storyboard is probably not too important. Just find some tutorials you like and work through them with whichever type of file (nib or storyboard) they use.
Are there any guidelines on when to use storyboards in an iOS project and when to use XIBs? what are the pros and cons of each and what situations do they each suit?
Near as I can tell it's not that clean to use storyboard segues when you have view controllers being pushed by dynamic UI elements (Like map pins).
Update 1/12/2016: It's 2016 and I still prefer laying out my UIs in code and not in Storyboards. That being said, Storyboards have come a long way. I have removed all the points from this post that simply do not apply anymore in 2016.
Update 4/24/2015: Interestingly Apple doesn't even use Storyboards in their recently open-sourced ResearchKit as Peter Steinberger has noticed (under the subheading "Interface Builder").
Update 6/10/2014: As expected, Apple keeps improving Storyboards and Xcode. Some of the points that applied to iOS 7 and below don't apply to iOS 8 anymore (and are now marked as such). So while Storyboards inherently still have flaws, I revise my advice from don't use to selectively use where it makes sense.
Even now that iOS 9 is out, I would advise against to use caution when deciding whether to use Storyboards. Here are my reasons:
Storyboards fail at runtime, not at compile time: You have a typo in a segue name or connected it wrong in your storyboard? It will blow up at runtime. You use a custom UIViewController subclass that doesn't exist anymore in your storyboard? It will blow up at runtime. If you do such things in code, you will catch them early on, during compile time. Update: My new tool StoryboardLint mostly solves this problem.
Storyboards get confusing fast: As your project grows, your storyboard gets increasingly more difficult to navigate. Also, if multiple view controllers have multiple segues to multiple other view controllers, your storyboard quickly starts to look like a bowl of spaghetti and you'll find yourself zooming in and out and scrolling all over the place to find the view controller you are looking for and to find out what segue points where. Update: This problem can mostly be solved by splitting your Storyboard up into multiple Storyboards, as described in this article by Pilky and this article by Robert Brown.
Storyboards make working in a team harder: Because you usually only have one huge storyboard file for your project, having multiple developers regularly making changes to that one file can be a headache: Changes need to be merged and conflicts resolved. When a conflict occurs, it is hard to tell how to resolve it: Xcode generates the storyboard XML file and it was not really designed with the goal in mind that a human would have to read, let alone edit it.
Storyboards make code reviews hard or nearly impossible: Peer code reviews are a great thing to do on your team. However, when you make changes to a storyboard, it is almost impossible to review these changes with a different developer. All you can pull up is a diff of a huge XML file. Deciphering what really changed and if those changes are correct or if they broke something is really hard.
Storyboards hinder code reuse: In my iOS projects, I usually create a class that contains all the colors and fonts and margins and insets that I use throughout the app to give it a consistent look and feel: It's a one line change if I have to adjust any of those values for the whole app. If you set such values in the storyboard, you duplicate them and will need to find every single occurrence when you want to change them. Chances are high that you miss one, because there's no search and replace in storyboards.
Storyboards require constant context switches: I find myself working and navigating much faster in code than in storyboards. When your app uses storyboards, you constantly switch your context: "Oh, I want a tap on this table view cell to load a different view controller. I now have to open up the storyboard, find the right view controller, create a new segue to the other view controller (that I also have to find), give the segue a name, remember that name (I can't use constants or variables in storyboards), switch back to code and hope I don't mistype the name of that segue for my prepareForSegue method. How I wish I could just type those 3 lines of code right here where I am!" No, it's not fun. Switching between code and storyboard (and between keyboard and mouse) gets old fast and slows you down.
Storyboards are hard to refactor: When you refactor your code, you have to make sure it still matches what your storyboard expects. When you move things around in your storyboard, you will only find out at runtime if it still works with your code. It feels to me as if I have to keep two worlds in sync. It feels brittle and discourages change in my humble opinion.
Storyboards are less flexible: In code, you can basically do anything you want! With storyboards you are limited to a subset of what you can do in code. Especially when you want to do some advanced things with animations and transitions you will find yourself "fighting the storyboard" to get it to work.
Storyboards don't let you change the type of special view controllers: You want to change a UITableViewController into a UICollectionViewController? Or into a plain UIViewController? Not possible in a Storyboard. You have to delete the old view controller and create a new one and re-connect all the segues. It's much easier to do such a change in code.
Storyboards add two extra liabilities to your project: (1) The Storyboard Editor tool that generates the storyboard XML and (2) the runtime component that parses the XML and creates UI and controller objects from it. Both parts can have bugs that you can't fix.
Storyboards don't allow you to add a subview to a UIImageView: Who knows why.
Storyboards don't allow you to enable Auto Layout for individual View(-Controller)s: By checking/unchecking the Auto Layout option in a Storyboard, the change is applied to ALL controllers in the Storyboard. (Thanks to Sava Mazăre for this point!)
Storyboards have a higher risk of breaking backwards compatibility: Xcode sometimes changes the Storyboard file format and doesn't guarantee in any way that you will be able to open Storyboard files that you create today a few years or even months from now. (Thanks to thoughtadvances for this point. See the original comment)
Storyboards can make your code more complex: When you create your view controllers in code, you can create custom init methods, for example initWithCustomer:. That way, you can make the customer inside of your view controller immutable and make sure that this view controller cannot be created without a customer object. This is not possible when using Storyboards. You will have to wait for the prepareForSegue:sender: method to be called and then you will have to set the customer property on your view controller, which means you have to make this property mutable and you will have to allow for the view controller to be created without a customer object. In my experience this can greatly complicate your code and makes it harder to reason about the flow of your app. Update 9/9/16: Chris Dzombak wrote a great article about this problem.
It's McDonald's: To say it in Steve Jobs' words about Microsoft: It's McDonald's (video)!
These are my reasons for why I really don't like working with storyboards. Some of these reasons also apply to XIBs. On the storyboard-based projects that I've worked on, they have cost me much more time than they have saved and they made things more complicated instead of easier.
When I create my UI and application flow in code, I am much more in control of what is going on, it is easier to debug, it is easier to spot mistakes early on, it is easier to explain my changes to other developers and it is easier to support iPhone and iPad.
However, I do agree that laying out all of your UI in code might not be a one-size-fits-all solution for every project. If your iPad UI differs greatly from your iPhone UI in certain places, it might make sense to create a XIB for just those areas.
A lot of the problems outlined above could be fixed by Apple and I hope that that's what they will do.
Just my two cents.
Update: In Xcode 5, Apple took away the option to create a project without a Storyboard. I've written a small script that ports Xcode 4's templates (with Storyboard-opt-out option) to Xcode 5: https://github.com/jfahrenkrug/Xcode4templates
I have used XIBs extensively and completed two projects using Storyboards. My learnings are:
Storyboards are nice for apps with a small to medium number of screens and relatively straightforward navigation between views.
If you have lots of views and lots of cross-navigation between them the Storyboard view gets confusing and too much work to keep clean.
For a large project with multiple developers I would not use Storyboards because you have a single file for your UI and cannot easily work in parallel.
It might be worth for large apps to split up into multiple storyboard files but I have not tried that. This answer shows how to do segues between storyboards.
You still need XIBs: In both of my Storyboard projects I had to use XIBs for custom table cells.
I think Storyboards are a step in the right direction for UI implementation and hope Apple will extend them in future iOS versions. They need to resolve the "single file" issue though, otherwise they won't be attractive for larger projects.
If I start a small size app and can afford iOS5 only compatibility, I would use Storyboards. For all other cases I stick to XIBs.
Storyboards were created to help developers visualize their application and the flow of the application. It is alot like having a bunch of xib but in a single file.
There is a question similar to this located What is the difference between a .xib file and a .storyboard?.
You can also create custom transitions via code that will change dynamically if needed, much like you can with .xibs.
PROS:
You can mock up flow of an application without writing much, if any code.
Much easier to see your transitions between screens and your application flow.
Can also use .xibs if needed with storyboards.
CONS:
Only works with iOS 5+. Does not work with iOS4.
Can get cluttered easily if you have a very view intensive application.
There really isn't a right / wrong when to use one or the other, it is just a matter of preference and what iOS versions you are wanting to use.
I will just state 4 simple reasons why you should use storyboards, especially in a productive environment where you have to work in a team of product owners, product managers, UX designers, etc.
Apple has GREATLY improved working with Storyboards. And they encourage you to work with them. Which means they will not break your existing projects with updates, they will ensure that storyboards are future proof for newer XCode/iOS versions.
More visible results in less time for the product owners and managers, even during the creation phase. You can even use the storyboard itself as a screenflow diagram and discuss it in meetings.
Even after an app is done (and that's generally where its life-cycle begins) – in the future it will be faster and easier to apply small adjustments. And these could very well change multiple aspects of your layout at the same time, which you probably want to see in a WYSIWYG manner. The alternative would be hand-writing UI changes in code and switching back and forth between the IDE and the simulator to test it out, each time waiting for compile & build.
Non-developers can be taught to set up layouts in storyboards and create the necessary hooks for the developers (IBOutlets and IBActions). That's a very big plus because it lets the devs focus on the logic and the UX designers apply their changes in a visual manner, without having to write any code at all.
I won't write up any CONS, since Johannes has already listed probably all the viable ones in his answer. And most of them are definitely not viable, especially not with XCode6's major improvements.
I don't think there is a right answer for your question, it's just a matter of personal experience and what you feel more confortable with.
In my opinion, Storyboards are a great thing. It's true, it's really hard to find out why your app is misteriously crashing at runtime, but after some time and experience you'll realize it's always related to some IBOutlet missing somewhere and you'll be easily able to fix it.
The only real issue is working in team under version control with storyboards, in the early stages of development it could be a real mess. But after that first stage, UI updates that completely changes the storyboard are very rare, and in most cases you end up with conflicts in the very last parts of the xml, which are segue references that usually autofix themselves when you re-open the storyboard. In our team work we prefered to deal with this instead of heavy view-controllers with tons of view code.
I've read many comments againts auto-layout. With XCode5 it got really improved, It's really good even for autorotating layouts. In some case you'll have to do something in code, but you can simply outlet the constraint you need to edit and, at that point, do what you need in your code. Even animate them.
I also think that most of the people who dislike storyboards didn't fully try to understand the power of a custom manual segue, where you can totally customize (in a single file) the way you transition from a way to another and also (with some tricks) even reuse a previously loaded view controller by just updating it's view contents instead of fully reload the whole thing.
At the end you can really do the same things as in code, but I think you have a better separation of concerns with storyboards, but I agree that in many things they lack of features (fonts, image as color background, ecc...).
I am not using StoryBoard or XIBs in my any of the app.. but creating everything programmatically.
∆ Benefits :
√ You can create any complex kind of UI or transition animations for UIView's.
√ Support all iOS versions. No need to worry about < iOS 5.
√ *Your app would support all iPhone/iPod/iPad devices within your code.
√ You're always updated as you know the code that'll always work.
√ *Will work on any (new) device launched – No need to change in code.
√ Everything is upto you. At certain place you want to change something – No need to look into storyboard or xib. Just search for it in particular class.
√ Last but not the list – You'll never forget that, how to manage everything programmatically. This is the best thing as you know a control very deep then anyone.
I've never find a problem by not using SB or XIBs as I'm good with this.
* if you've set UIKit's object frames according to screen size.
P.S. If you've still not done this thing – you may faced difficulty (or may feel boring) but once you get familiar with this – its really a Candy for you.
If you are about to care about Storyboard performance, watch WWDC 2015 Session 407
Build Time
When interface builder is compiling a storyboard it's doing two things
first, it's trying to maximize the performance of your application and
secondly it's also minimizing the number of nib files created.
If I have a view controller with a view and a bunch of sub views,
interface builder, the build time is going to create a nib file for
the view controller and create a nib file for the view.
By having separate nib files for both the view controller and the
view, this means the view hierarchy can be loaded on demand.
Run Time
When you allocate a storyboard instance using UI storyboard, API,
initially all you are allocating memory for is the UI storyboard
instance itself.
No view controllers no views yet.
When you instantiate your initial view controller it will load the nib
for that initial view controller but, again, no view hierarchy has
been loaded yet until someone actually asks for it.
I have been working on a reasonably sized project (>20 scenes in storyboard parlance), and have come across many limitations and have to repeatedly go to documentation and google searches for doing things.
The UI is all in one file. Even if you create multiple storyboards, you still have many scenes/screens in each storyboard. This is a problem in medium-large teams.
Secondly, they do not play well with custom Container Controllers which embed other container controllers etc. We're using MFSlideMenu in a Tabbed application and the scene has a table. This is almost impossible to do with a storyboard. Having spent days, I've resorted to doing the XIB way where there is complete control.
The IDE does not allow to select controls in zoomed-out state. So, in a large project, the zoom-out is mostly to get a high level view and nothing more.
I would use storyboards for smaller applications with small team sizes and use XIB approach for medium-large teams/projects.
If you want to reuse some UI in multiple view controllers then you should use XIBs
New to iOS, coming from the Java / Swing world, where I'm used to creating UIs programmatically, letting components size themselves and using various clever layout managers to arrange things.
It already seems clear that the iOS way is to make heavy use of Interface Builder, with a lot of fixed sizing and positioning. I'm not sure IB is ever going to come naturally, but I guess fixed layouts make sense given that you're working with limited space and a fixed window size.
It still seems like I'm writing a lot of boilerplate, though, and violating DRY, and so on.
Can somebody point me to a good primer on laying out iOS UIs, particularly programmatic UIs?
You don't really need to use IB to write MonoTouch apps. I almost never do. The CocoaTouch API is fairly simple and straightforward to develop on.
I haven't really found any writeup on UI development other than the apple documentation (which is really good, by the way, worthy reading), so here goes a couple of tips, based on my experience:
Inheritance is key to maintaining the code clean. You can inherit from basically any class in the API, like buttons, controllers, views, etc. Inherit and add your customizations in those classes. Don't shove everything in the AppDelegate like many examples show. You'll thank me later on.
Have I mentioned inheritance already?
The one thing iOS doesn't have is a layout manager, so if you're used to Java like you mentioned, this will sound a little strange. Different from what Java people think, this is not a big deal. UITableViews help tremendously with this (vide next point).
A lot of iphone apps are built on top of the UITableViewController, even apps that don't look like tables. It's a great framework to do anything related to scrolling. Learn to use it well. Almost anything that scrolls vertically is a UITVC. Follow the guidelines that define when you create and when you dispose cells and objects.
Be careful every time you add a Frame location in your control. Instead of setting hardcoded values, try using offsets from other locations (x+40, for example) whenever possible.
Make sure you add your views to the proper container as necessary. For example, if you're adding a global "Loading" view, add it to the Window object, while if you're adding a image on the left side of a table cell, use the ContentView. iOS changes those special views automatically all the time (resizing screen to fit "on call" bar at top, or rotating phone).
Miguel de Icaza has created a great framework for managing forms and tables, called MonoTouch Dialog. Take a look, and enjoy.