0

i developed iphone application and finished everything that fits on 3.5 inch display. i also need the same thing to be fit on 4 inch display. I set the splash screen and home screen and its display fits on both the devices. Then tried Use auto layout for other pages. its not working. Could you please tell me how to set the other screens.

Thanks in advance.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Please do some research before posting a question. This has been asked over and over before. – rmaddy Mar 22 '14 at 06:04

2 Answers2

0

Put following macro in yourAppName-Prefix.pch

#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )

So you can use anywhere in your project.

And put condition such like

if (IS_IPHONE_5)
{
     //iPhone  4 inch
}
else
{

     //iPhone  3.5 inch
}

Also for more information read this question/answer.

Community
  • 1
  • 1
iPatel
  • 46,010
  • 16
  • 115
  • 137
0

You should set the dynamic frame instead of Hard-coded frame,

You can use [[UIScreen mainScreen] bounds]; to determine the device height and width.

For example:

CGRect frame = [[UIScreen mainScreen] bounds];

UIView * myView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, frame.size.width, frame.size.height)];

[self.view addSubview:myView];

myView = nil;

Thanks!

Natarajan
  • 3,241
  • 3
  • 17
  • 34