I used constant coordinates in the code in several places of my iPhone application, especially when I programmatically create a view by setting the properties of the uiview subclasses.
Example:
UIImage* img = [UIImage imageNamed:@"background.png"]; UIImageView *imgView = [[[UIImageView alloc] initWithImage: img] autorelease]; imgView.center = CGPointMake(160, 175); // --> Are these constant usages safe? [self.view addSubview: imgView];
I tested it on a simulator, 3G device and 4S, and it works. Should I worry about future device solutions or any other bugs? If so, how do I make this piece of code more secure? Any coding principles here?
Thanks Mbh
This is not a big problem in most cases, but it is always better to use a link.
, , screensize.width/2 160, , -, , , -, , . navigationBar.frame.size.height 44 ( ). , , , , ;).
screensize.width/2
160
navigationBar.frame.size.height
44
, , , , .
- , API, , . ? API, ? ? ? .