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 5839637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:36:44+00:00 2026-05-22T11:36:44+00:00

I have an iPhone game and I want to convert the project into a

  • 0

I have an iPhone game and I want to convert the project into a universal one. In fact, I have done so already by adjusting the target.
The problem is: For example the UIButtons don’t resize and don’t relocate.

Question: What is the correct way to create a button so that it automatically adjusts its size if the universal app is run on the Pad?

At the moment I’m making buttons like so:

    [self setSettingsButton:[UIButton buttonWithType:UIButtonTypeCustom]];
    [settingsButton setFrame:CGRectMake(38, 121, 30, 180)];
    [settingsButton setBackgroundImage:[UIImage imageNamed:@"SettingsButton.png"] forState:UIControlStateNormal];
    [settingsButton addTarget:self action:@selector(prefButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:settingsButton];

Well yes, obviously, the positions and sizes are absolute when they should be relative but my question is: how to make them relative?

Many thanks for your help!

  • 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-05-22T11:36:45+00:00Added an answer on May 22, 2026 at 11:36 am

    I see two ways in this situation:

    1)

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        [settingsButton setFrame:CGRectMake(38, 121, 30, 180)];
    }
    else {
        [settingsButton setFrame:CGRectMake(131, 145, 60, 250)]; // your iPad values
    }
    

    2)

    CGRect bounds = self.view.bounds; // Here we get VC views frame size
    CGRect buttonFrame = CGRectZero;
    buttonsFrame.origin.x = bounds.size.width * 1.0/3.0;   // Yours calculations
    buttonsFrame.origin.y = bounds.size.width * 4.0/5.0;   //
    buttonsFrame.size.width = 240;                         //
    buttonsFrame.size.height = 300;                        //
    [settingsButton setFrame:buttonsFrame];
    

    Hope this’ll help!

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

Sidebar

Related Questions

I have started looking into iPhone game programming. I want to build a game
I am creating an iPhone game. I want to have a button in my
I have an array of scores in my iphone game. All I want is
Hi I want to implement a very simple game on iphone. I have a
I am creating a free version of my iPhone game. I want to have
I have an iPhone game which I am porting to PC. The game uses
I have a pretty basic challenge-based iPhone game, and I wanted to know what
I am making an iPhone game. I have all the required app sizes except
I am developing an iPhone game in which birds bounce. I have set up
I'm currently developing a doodle-jump style game in Cocos2d for iPhone and have a

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.