iPhone - Handling two xib's depending on initial orientation
In my application there I'm maintaining two xib files "MyView_Portrait.xib" and "MyView_Landscape.xib" but view controller is same for both. I'm maintaining two xib's because, i want to load respective orientation depending on device orientation or when orientation changes. Also there are many controls in my views and I want to show different images in portrait and landscape views. This is working fine.
But I'm not able to load the appropriate xib 开发者_如何学编程when the app starts.
In - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
I'm using the code
if(UIInterfaceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
to identify the orientation. But its always returning the orientation as landscape. How can I achieve the task of loading appropriate view when the app starts up? I'm maintaining two viewcontrollers in the application delegate header file
Check your project's info.plist and make sure you list all 4 supported orientations under the key:
Supported interface orientations
精彩评论