Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different Xib's for Portrait and Landscape mode for iPad

I have doubt in using 2 XIb's for one class changing on orientations for Ipad. Is it right practice to do? For Ipad in Portrait mode I have one design and for landscape mode I have different design (little similar to portrait, but can't adjust' in portrait). Can I do everything in programming or its fine in using 2 Xib's, what are the complexities or issues I should face in using 2 Xib's?

like image 961
gopal Avatar asked Jan 06 '12 11:01

gopal


People also ask

How do I force an app to landscape on IPAD?

Make sure that Rotation Lock is off: Swipe down from the top-right corner of your screen to open Control Center. Then tap the Rotation Lock button to make sure it's off.


1 Answers

If you're asking if using two NIBs for your orientations is standard practice then the answer is no.

If your UIs for landscape and portrait are radically different then it would be a more acceptable approach. But you could easily just use a single NIB with two views inside it (one for landscape, one for portrait) instead.

The accepted design pattern that Apple put forward is your view controller manages both landscape and portrait orientations, and either adjusts its view (using autoresizing masks, and also hooking into the various delegate methods triggered upon rotation to add/remove/animate views) or replaces the view with something else.

If your landscape/portrait views are quite different I'd recommend having a single NIB with two views inside it (one for landscape, one for portrait) and adding/removing those two views inside your view controller when you detect rotation.

'Standard practice' is always quite difficult to define, and perhaps some people will disagree with me, but I certainly haven't seen any apps that use two NIBs for their landscape/portrait orientations, and I haven't seen any Apple sample code that does it either. Hope this helps!

like image 103
lxt Avatar answered Nov 15 '22 09:11

lxt