0

I am getting positions/coordinates(x and y values)from server in inches. How to convert from inches to pixel which is support to retina and without retina. Please help me.

float x= 0.916667;
float Y= 7.885417

float deltaX = x * 72;
float deltaY = y * 72;

UIActivityIndicatorView *avtivity=[[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(deltaX, deltaY, 20, 20)];
[avtivity startAnimating];
avtivity.activityIndicatorViewStyle=UIActivityIndicatorViewStyleGray;
[imgView addSubview:avtivity];

enter image description here

I need to display ActivityIndicatorView on the top off START button in the above screen.

Ganesh G
  • 1,991
  • 1
  • 24
  • 37
  • 4
    http://stackoverflow.com/questions/610193/calculating-pixel-size-on-an-iphone – Dmitry Khryukin May 27 '13 at 05:11
  • Why do you assume that iOS is 72 ppi? In fact it is not, and in fact many iOS devices are different. What is your goal here anyway? 7 inches will be off the screen of *any* Apple phone device. – borrrden May 27 '13 at 06:38
  • According to iphone5 i need to do float deltaX = x * 325.97; float deltaY = y * 325.97; based on formula inches*dpi=pixel. But the activity is showing some where. – Ganesh G May 27 '13 at 06:49
  • I repeat: Look at your Y value!! Nearly 8 inches. You expect it to stay on screen with that kind of offset? – borrrden May 27 '13 at 06:56
  • No, I just want to display activity indicator on the start button – Ganesh G May 27 '13 at 07:06

1 Answers1

2

you should be using resolution independent points... points are 12 to a pica, which are 6 to an inch, so 1:72.

from points to inches: f(x) = x/72

the reverse, inches to points: f(x) = x*72

Grady Player
  • 14,399
  • 2
  • 48
  • 76
  • Thank you for reply, It doesn't work for me. Ex: i am getting y position y = 7.88542 inches. if i do 7.88542*72=567.75, the vies is going to out. There is half off difference between original to this. – Ganesh G May 27 '13 at 05:21
  • i am not sure that I follow... what does "the vies is going to out" mean? – Grady Player May 27 '13 at 05:33
  • i need to show small view on the main view with the help of coordinates which is getting from server. When applied these coordinates to small view it is not placing exactly. – Ganesh G May 27 '13 at 05:43
  • can you give a small example in code? – Grady Player May 27 '13 at 06:00
  • I have updated question with some code. Please have a look. – Ganesh G May 27 '13 at 06:21