I’m programming an iPhone app and I’m wondering how programmers properly position controls without using Interface Builder. More or less, this is because I want to position a couple of controls without using Interface Builder.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Try using the IB to see the coordinates at which you would like to position your objects and then add them in code. You will usually need to do some trial and error to get it right.
You might also want to position items relative to the size of the screen. In this case I would suggest avoiding hardcoding the size of the screen in the app like
480/2. Instead, use the UIScreen’s shared object to get the current screen’s size like this:(example to position a UIView in the center of the screen – any screen, iPhone, iPad, iPad external screen)