I hate Interface Builder. I hate the way iOS deals with layouts. I must be doing something wrong, if you have any suggestions I am totally open to them.
Here is the stupid layout for a simple enter the patient name view controller.
Last [ ]
First [ ]
Middle [ ]
That is it, three stupid labels and three stupid text fields. I want them to show up in both portrait and landscape mode with room for the keyboard to appear without overlaying them.
First off I drop the fields on the View align them to the top of the view. Run the code and guess what? Last is under the damn navigation bar. Why does this happen? Why are the controls not automatically moved down? What the hell am I missing in IB? I don't even know what to search on in Google to find out and I have tried. If you turn on a navigation bar in IB is just shows how much screen spaces it uses but it does not affect the way it operates when you run the program. That is not what I expect from the self appointed Gods of UI at Apple. I tried all kinds of autosizing anchoring and most made it way worse, moving the controls as I rotated so they overlapped each other.
So I move all the stupid controls down in IB and get them to show up in the running program. Then I rotate to landscape and guess what? It looks like crap again. You can't design for both portrait and landscape in IB, pick one ONLY. Everything else you have to do in code unless you want to double the fun in IB and then double all your connections in the code and double the reason you want to fly out to California and start smacking people for having such a crappy way of doing this.
Your other choice, and the one I took as I have had to do this is other areas of the code already, is to manually move controls on orientation changed notification. What a massive waste of code and time. I hardcoded, as that seems to be the Apple way again, the move value. Since the navigation bar is 44 pixels high in portrait and 32 high in landscape I move everything 12 pixels. What if Apple were to change this size? A lot of broken code that is what would happen.
I added the waste of variables, 6 floats in all, to the controller to remember the Y position of each widget during initial view load. I adjust all the controls when the view appears as could appear in the seemingly evil landscape mode of course and when it rotates. It all works now, things appear just below the navigation bar and just above the keyboard in both modes. The text entry fields expand to fit the width.
Really people, this is so easy to do on the Android. I don't go through this hell when I do portrait and landscape. I don't have to make stupid adjustments to account for a navigation bar or to write a bunch of worthless code. What if I had 12 controls?
The Android layout manager GUI editor is not as slick as IB, really pretty barren, and I have to tweak the XML but it works in both portrait and landscape and it does not screw me over when I have a navigation bar. Controls can be relative to other controls so moving one can move a whole group. If I want to make portrait look different from the landscape I just do a second XML file with the landscape suffix using same IDs and the OS deals with it. I don't have to manually code the crap out of all of it. I can rotate in the ever improving GUI editor to see how it looks. If I need to use another language things can flow to match the new text.
IB needs to take the navigation control into account. IB needs to allow you to create both portrait and landscape layouts without doing double connection work. IB needs an overhaul, it is not friendly to use, it is not obvious what to do, it has a crappy user interface. It does not open the correct associated file when you want to drag and drop connections. It fights me constantly. I hate to create a new view controller as I know the next part of my day is going to suck.
I am ready to drop kick IB to the curb. I know many iOS developers have already done that. Creating and positioning everything in code, which I am half doing already, is as old school as you can get. Really, that is the solution from the "Graphics and UI masters" of Apple? I have not started on the iPad side of things yet but I am guessing is a new nightmare ready to scare me right back into Linux / PC and the Android. The Doctors want this running on the iPhone but I have to say I can not recommend the iPhone to anyone for use or coding after all the hell I have dealt with on it. The Android side is so much cleaner and easier to do in my coding opinion.
If you have not coded on both then please don't tell me I just don't get it. If you know how to make IB in the list bit usable I beg you to post a comment or a link to a site that covers how to make it work. If you have given up on IB tell me how wonderful life can be without it shackles.