How to make xib compatible with both iphone 5 and iphone 4 devices

前端 未结 14 1805
执念已碎
执念已碎 2020-11-28 20:39

I am trying to layout my xib so that layout fits in both iphone 5 (4 inches retina) and 3.5 devices.

Because I have to support IOS-5 I cannot use autolayout. I have

14条回答
  •  北海茫月
    2020-11-28 20:54

    If your UI is too complicated and contains too many UIControls , then I suggest to do the following in viewDidLoad():

    NSLog(@"Iphone %f ",[[UIScreen mainScreen] bounds].size.height);
    if ([[UIScreen mainScreen] bounds].size.height == 568) 
    {
         //design frames of your controls accordingly add add the controls as subview to
         self.view            
         //this is iphone 5 xib
    } else 
    {
         //design frames of your controls accordingly add add the controls as subview to
         self.view 
         // this is iphone 4 xib
    }
    

提交回复
热议问题