简体   繁体   中英

Making universal build for iphone application with xcode 4.51

I had an old project which uses XIB for each UIViewControler.That was intended for I Phone but now I want to make that project with universal build that is for Iphone as wall as IPad also.The problem is that when I changed the build type to Universal and used coding like

if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
    {
 // ipad coordinates
    }
else
{
 //iphone coordinates
}

this the display is correct on iphone and ipad but on ipad the buttons are not taking click event on entire button but only on a small portion of button.Though I am not loading Nib but it is taking crated iphone xib file internally and I think thats why it's button behavior is not in accordance to ipad view. I am confused that what I should do?How to make copy of XIB for Ipad and load them depending upon device.It is to mention here that I am not loading any nib from my code but It is being called internally. Please help

For universal app you can make 2 xib
1 - > yourView_iPhone
2 - > yourView_iPad

And load each xib according yo your idiom

if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
    yourView  *obj = [[yourView alloc]initWithNibName:@"yourView_iPad " bundle:nil];

    // ipad coordinates
}
else
{
    yourView  *obj = [[yourView alloc]initWithNibName:@"yourView_iPhone " bundle:nil];

    //iphone coordinates
}

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