Why doesn't my view auto resize after rotation?

I have an app using the splitscreen controller. The detail view part of it does not resize when the iPad orientation changes. All the objects in the view remain the same size. Is my assumption about autoresizing wrong? Do I need to develop 2 different views, one for portrait and one for landscape? Then what about ipads with differenct screen sizes? Before you flame me, I did look in the documentation. This is just a general question. All I need to know is if the views are supposed to autoresize or not and if so, how.

Thanks.

They will only resize if you've added layout constraints (or specified an autoresizing mask) to tell them to resize. What constraints did you add in the storyboard?

>This is just a general question.

That's fine, but can you relate which orientations you've elected via info.plist?

First, I do have all orientations enabled. And by contraints, do you mean the resizing box that has the arrows? If so, then I have the four arrows selected pointing to each side. I've tried many different combinations and nothing seems to work properly. In my xib file, I have my view laid out in portrait orientation and it stays that way even when the ipad is rotated to landscape. The view rotates but it just displays too large and off the screen. This is an old app and used to run on the older IOS. Since going to IOS 8 it became a problem. Is there something about IOS 8 that would cause this?

Ok so I finally figured out that my constraints were wrong in my interface builder. After correcting that, the view now resizes correctly after rotation. However, there is now another related problem. The resizing does indeed work now but ONLY if I start up the app while the ipad is oriented in portrait mode. Then when I rotate the ipad to landscape it resizes nicely and also when I roteate back to portrait. But, if I start the app up while the ipad is oriented in landscape, the view is too large again. It looks like the portrait size. Now when I rotate to portrait, it's way out of wack. Wassup wit dat?

Ok, after seeking help on both the raywenderlich and this forum and getting none, I've kind of given up. There may not be an answer. So I am thinking about a complete rewrite and I would like some opinion on this. First of all, I know that Apple is phasing out Objective C and I will have to learn Swift sooner or later. But I have heard that it is similar to Microsoft C# which I know very well. So maybe not so bad to learn. What I would like to know from all of you is do you think it is a good idea to just start over and rewrite the entire app in Swift? It's not a trivial app. There are lots of custom mathematical functions. Is it a big job to port over all those functions to Swift? There are also lots of images. Has anyone ever done anything like this?

I'm going to also post this on the Apple forum.

Thanks for your opinion.

No doubt there is an answer. You probably don't need to rewrite it in Swift. It sounds like something wrong with your layout in IB. From your first reply it sounds like you're not using auto layout but the "old school" autoresizing mask instead. Now might be a good time to brush up on auto layout and convert your storyboard / XIB. There are a couple of good talks from WWDC this year "mysteries of auto layout" which should help.


Since the forum is crippled by not allowing us to post images, it's hard to tell what might be wrong in your IB setup. Would be easier if you could post a screen shot. And of course if you're doing anything at all in code when it comes to setting up that view, it would be helpful to post that.

1. The implementation language is completely independent of your layout issues.

2. Don't expect Objective-C to go away anytime soon. Swift is probably the future preferred language for iOS apps, but its not exactly ready to displace Objective-C at this time.


3. As for your layout issues, are you testing with the simulators or on a real device? I've definitely seen cases in the Simulators where they don't always pick up on orientation changes the first time around.

4. Also, if you are using Size Classes make sure you have not accidently changed something there for compact/compact.

You are right in that this whole app is old school because that's when it was written. Not even using story board. Everything the hard way :-) BTW, why doesn't this forum allow images? How are we supposed to present our problems? I will take a look at "mysteries of auto layout" as you suggested. Thanks.

I've tested mostly with simulators but also with my iPad with the same results. Not using size classes. Thanks for your response. I appreciate any and all comments. I'm going to try to educate myself a little better about auto layout and constraints and such. Sure wish we had a local group where we could all meet in person and actually look at each others' apps. Anyway, thanks again to all for your comments.

I went through the WWDC "mysteries of auto layout" and learned a lot. However, the best I've been able to do is get everything to work perfectly ONLY if I start the app in portrait orientation. I honestly don't know where to go from here.

Eureka! I solved my problem! Quite by accident really. I'm not quite sure why this fixed my problem but it did. BTW, as I said earlier, this all worked on pre IOS 8 versions. But anyway, all I did was move one line of code the did a "insertSubview" from my main view controller's "viewWillAppear" method to the Appdelegate "application" method. I'm sure this may be obvious to many of you but it wasn't to me especially since it always worked before IOS 8. Thanks to all for your help. If nothing else, it got me thinking in the right direction and in the meantime I learned a lot about auto layout.

Why doesn't my view auto resize after rotation?
 
 
Q