문제

I've been writing iOS apps for a while now and gradually went from doing the UI entirely programmatically to using the Interface Builder intensively. I'm now thinking about using the new Storyboarding feature for some of my new projects, but I don't have enough experience or knowledge with it to calculate the advantages and disadvantages of doing so. Can anybody give some examples or information about when using Storyboarding payed off and when it was a waste of time?

도움이 되었습니까?

해결책

Advantages of Storyboarding

  • It's cool - suave way to design interfaces
  • Use of StoryBoardSegues to identify navigation/modal relationships
  • If your app supports multiple devices, good way to organize different views (by storyboard file rather than naming, etc)
  • Nice for prototyping
  • Prototype UITableViewCell can save time

Disadvantages of Storyboarding

  • It's a runtime feature, so I believe it is only available in iOS 5
  • StoryBoardSegues are kind of rigid in my experience and you may make use of prepareForSegue a lot
  • Like IB, not very friendly with other display engines and toolkits
  • Makes it hard to share designs for a single view or set of views - you have to send all or nothing

These seem kind of superficial, I guess I haven't given it much thought... At first I was gung-ho about story boards, but now I've reverted to IB or even just programatic view configuration... The more I use them, the less I like them, and the more they feel like a gimmick/waste of time.

Edit

I wrote this answer a few years ago. I have left it the same as before for posterity, although some points are likely no longer relevant (ie the fact that it requires iOS 5+).

After some time, my opinion hasn't changed on storyboards. As others have mentioned, they're okay if you are working solo on an app with few views to manage, but they become a real pain with source control & collaboration. In addition, I prefer one-file-one-object, and storyboards obviously bundle stuff together (as does IB, but to a lesser extent).

If I were writing an app meant to be maintained for any serious length of time, I would go with programmatic view configuration over IB, but definitely IB over storyboards.

다른 팁

Another disadvantage with Storyboarding not mentioned is that merges can be very difficult if not impossible if there are conflicts.

Update: It also occurred to me that it puts logic in two places. If your segue is not doing the right thing it might be because of an error in prepareForSegue or it might be because you named your segue incorrectly. Doing things programmatically is, in the end, not that hard.

At the latest WWDC (2013) Apple Devs strongly recommend using storyboard and built in IB stuff to do most of your code for you instead of writing it by hand because you are much more likely to avoid deprecation and take advantage of feature updates via automated conversions.

The lone disadvantage is the difficulty in allowing git collaboration on storyboards, as there will be conflicts on virtually every commit.

If you are a solo programmer, you should always be using storyboards.

I have a similar background to you - I started with mostly building my iOS UI programmatically since IB was not really user-friendly, but lately decided to use IB more and more, since it is better for designing the UI and works fine for standard-elements.

With the new Xcode I switched to Storyboard, since they provide a full view of the application. It is possible to generate the complete UI (with all views) in a single File, which can be used for prototyping and which I can view my colleagues before writing the first code line. It is far better and easier than designing with photoshop or similar tools.

However if you use a lot of your own UI elements/controls or something using a different "engine" (cocos2d, OpenGL, etc.) it is usually better to generate the UI programmatically, since these "engines" are not really integrated with IB/Storyboards.

I have learn the storyboarding by following the tutorials from the raywenderlich's website and there is a lot of stuff about the storyboard.

Here is the link to site: http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

Advantages of storyboard:

1) Before you start developing app you can see all the screens of the app.

2) You can visually see the relationship between each screen.

3) It can help to reduce the amount of the code specially in case of UITableView you can use prototype cells and static cells to design your TableView in storyboard.

4) In case if you have to work on someone else code you can get the better understanding of the flow of the app by viewing storyboard in short time.

5) You can setup the user interface for iPhone 4 and iPhone 5 by applying the retina form factor from storyboard, without running the app again and again.

6) If you are doing client based work then some clients want to see the prototype of the app before start developing it, here storyboard helps you a lot.

Disadvantages of storyboard:

1) For storyboard you will need a big screen specially in case of iPad.

2) I also experience a difficulty while copying views from other apps to storyboard.

3) I also experience problems in storyboard when multiple developers work on the same project by using git repository.

By reading and understanding the advantages and disadvantages you can judge your self when to use storyboard.

One Word (DON'T) One of the biggest disadvantages of storyboard aside from the git conflicts that make it impossible for two or more persons to work on it. but also if the project went so big and you have +40 screens , if you insane enough to move anything just one pixel in any view controller you have in the storyboard, you'll have a very huge compilation time, that you can build your app and make it run in more than 5 minutes, and of course don't let me start with archiving to give some one adhoc of the app .

after this painful experience I totally fell back to the oldy goldy great xib files and deleted the storyboard file in a huge fire celeberation .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top