4

I have a question about universal app. My app will not have storyboards or xib file. There is possibility to write universal iPhone/iPad application without it? I found some tutorial how to create universal app with storyboard, but i don't want (i can't) use this feature in my project.

If it is possible What should i do? If i have to made changes only in ViewControllers? I'm start to do this, i'm not changing old project so i can do anythng - what should i learn/what should i remember?

I'm targeting to iOS 5.

EDIT:

I have a screen information in resource file and my rootViewController or any other ViewController will be created in compile time, so i can't have xib file for that, i can't put button on xib with Interface Builder becouse i don't even know how many buttons i will have there. I don't know how many screens i've got till i hit run in my project.

Jakub
  • 13,712
  • 17
  • 82
  • 139
  • 2
    Just write the app in C! http://stackoverflow.com/questions/10289890/how-to-write-ios-app-purely-in-c/10290255#10290255 @Adam in the future, please put all dupe links in one post next time. – Richard J. Ross III Jul 03 '12 at 15:29

2 Answers2

5

Not only can you write any type of iOS app without Interface Builder, it is actually much more testable and pliable. Some auto layout tricks are difficult (not possible?) in IB style projects, as well.

There is an incredibly impressive library called Masonry that wraps the NSLayoutContraint syntax. This makes it quite pleasurable to subclass views while not having to use ugly VFL or incredibly verbose NSLayoutContraint syntax (not even going to address frame setting...blech!). IB style apps also promote bad software development practices and anti-patterns (just dumping everything in a view controller presentation-wise. No Separation of Concerns!). Also, it is more difficult to work on larger teams (IMHO even small teams) while utilizing Nibs, Xibs, and Storyboards due to merge issues.

On top of all of that, you gain a much deeper understanding of the classes you are working with (UIView, UIResponder, etc.) when writing code in this manner (once again IMHO). There is an interesting article outlining some of these issues in more detail: http://doing-it-wrong.mikeweller.com/2013/06/ios-app-architecture-and-tdd-1.html This is by no means the only article that discusses this problem. Also, this will help for your app delegate: creating a universal window-based iphone app without generated xib file

Community
  • 1
  • 1
dotToString
  • 230
  • 2
  • 13
4

This is certainly possible, I have only used storyborads once in the many apps I have published. As for not using XIBs, I am not sure why you would want to do that. You can lay out your views at runtime in the init method, but I feel like that is just making things unduly hard on yourself. You can set a XIB up for the iPad and one for the iPhone so you can tailor the UI specifically to each device.

Perhaps if you go into a bit more detail about why you are imposing this requirement on yourself we can discuss if it si worth the effort to go down that road.

Good Luck.

MystikSpiral
  • 5,018
  • 27
  • 22
  • 1
    I have to do this becouse in runtime, i might don't know what is my root screen should look like. And i don't mean record in table view. This could be tableView, scrollView so on, so on.. – Jakub Jul 03 '12 at 17:01
  • I've just edit my original post. As far I understand to this project i cannot use xib or storyboards. – Jakub Jul 03 '12 at 17:07
  • You need to spend a bit more time with the architecture I think You can create a basic XIB and then init using that XIB and any number of different view controllers. Once you define each View controller instance as an IBOutlet expected by the XIB, you are off and running. This is why the View Controller has a constructor called "InitWithNibName". It allows that view controller to plug into any XIB you wish. – MystikSpiral Jul 03 '12 at 20:48
  • 3
    XIBs/Storyboards are slower than code, add to the size of your app, aren't as readable in git commits, and aren't as modular as code. Check yourself before you wreck yourself. – Nate Symer Jun 22 '15 at 20:21