问题
How can a view controller be make compatible with iphone 5 if it's xib file not taken. Is it possible to make that change programmatically. Thanks in advance.
回答1:
Yes defiantly you can do this. XIB are just files too just open one in a texteditor - you'll see that it consists of readable xml code. now for making viewController compatible with Iphone 5 just put if else condition and make thing separately for different devices by checking height of particular device
but defiantly its going to be long job
For my universal app, Forex App, I'm simply using the screen height detection concept like so:
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
if (screenSize.height > 480.0f) {
/*Do iPhone 5 stuff here.*/
} else {
/*Do iPhone Classic stuff here.*/
}
} else {
/*Do iPad stuff here.*/
}
回答2:
check the device is iPhone 5 or not and set frame programmatic..
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
if (screenRect.size.height >= 548 )
{
// set your frame for iPhone 5
}else
{
// set your frame for iPhone 4
}
回答3:
Yes you can do that by adding the following condition
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
iPhone 4 or less
}
else if (result.height == 568)
{
iPhone 5 condition
}
Wherever you want to differentiate between the two phones.
来源:https://stackoverflow.com/questions/16351616/how-to-make-the-view-controller-compatible-with-iphone-5-if-xib-not-taken