简体   繁体   中英

How can I change a window orientation to landscape in XCode 4 Interface Builder?

I appreciate I'm probably missing something basic here, but...

My iPad app will only support landscape mode, and has a MainWindow.xib Window that I'd like to work on in landscape mode in XCode 4, however the pull-down menu to change this (Simulated Metrics -> Orientation) is always grayed out.

I notice that Views can be rotated just fine, it's only Windows that can't be rotated in XCode 4 using this setting.

Is there a workaround for this, or do I have to put a View on top of the MainWindow in order to rotate it?

I think it's because apps always starts up in portrait and then rotates to appropriate oriantations. From the UIViewController docs:

Note: At launch time, applications should always set up their interface in a portrait orientation. After the application:didFinishLaunchingWithOptions: method returns, the application uses the view controller rotation mechanism described above to rotate the views to the appropriate orientation prior to showing the window.

So you'll need the UIViewController magic for the simulated metrics to make any sense. If you used the "Window-based application" template as a starting point for your project try the "View-based application" template instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM