Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7784591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:07:09+00:00 2026-06-01T20:07:09+00:00

I have used constant co-ordinates in code in several places in my iPhone app,

  • 0

I have used constant co-ordinates in code in several places in my iPhone app, particularly when I am programmatically creating a view, setting properties of 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 have tested it on simulator, device both 3G and 4S and it works.
Should I be worried for future device resolutions or any other gotchas?
If so, how should I make this piece of code, more safe? Any coding principles here?

Thanks
Mbh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:07:10+00:00Added an answer on June 1, 2026 at 8:07 pm

    It’s not a big deal in most cases, but it’s always better to use a reference.

    For example, if your image view is at the middle of the screen, you could use screensize.width/2 instead of 160, it’s the same in theory, but first, it’s more clear what you are doing, and second, if the screen were to change, you’d be prepared. Another example would be to use navigationBar.frame.size.height instead of 44 (which is not likely to change anyway).
    Also, if you reference other views you laid yourself, and you move one, all of them will move with it ;).

    In short, if you have a reference you can use, use it, otherwise, don’t worry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the following article as a guide to creating a custom EditorPart
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have used full text search mysql. My code is select * from uh_property
Is it possible to have a warning when a multicharacter constant is used in
I have a constant defined with screen width to 320. This is being used
I have seen these two approaches for constant declaration which are to be used
I used to have a straight up controller returning a view like this return
i have need of a constant which can be used in my three different
I have seen and used C++ code like the following: int myFourcc = 'ABCD';
I have used the following as comments in my .emacs // {{{ // }}}

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.