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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:35:16+00:00 2026-06-01T00:35:16+00:00

I create some buttons dynamically on my view and i decide their frames according

  • 0

I create some buttons dynamically on my view and i decide their frames according to some of my JSON respone parameters. But i want to autoresize them when the device(dsimulator) rotates. I can easily do this on interface builder but can’t do anything on dynamic ones. Can someone help?
EDIT

Here is a snipped of my code

if (button.tag==1) {
    button.frame = CGRectMake(30.0f, yPosition, 200.0f, buttonHeight);
}
if (button.tag==2) {
    button.frame = CGRectMake(280.0f, yPosition, 200.0f, buttonHeight);
}
if (button.tag==3) {
    button.frame = CGRectMake(530.0f, yPosition, 200.0f, buttonHeight);
}

There is no problem when using Portraid mode but when it rotates to Landscape a big empty area stays on the right side of the screen. How can i fix this?(I mean, when i rotate, i want the buttons got to the center of the scren’s width)

EDIT:
I played with autoresizing on Size Inspector(Xcode 4.3) with my xib file and it works great, but whatever i did i couldn’t resize the dynamically created buttons after rotation. I tried almost all of AutoresizingMask enums of UIView but nothing changes. Can someone please 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-06-01T00:35:17+00:00Added an answer on June 1, 2026 at 12:35 am

    The attributes you’ve set up in your interface builder file are the UIViewAutoresizing attributes.

    Take a look at this documentation from Apple on the UIView class (which your button is a subclass of); look for the UIViewAutoresizing attribute. That’s the one you’ll want.

    Update: Here’s a snippet of code for an MKMapView that uses this ability:

    mainMapView = [[MKMapView alloc] initWithFrame:CGRectMake(20, 239, 280, 122)];
    [mainMapView setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin];
    

    With UIViewAutoresizingFlexibleTopMargin, the map view moves down when the user answers the phone — it fixes the map’s position relative to the top of the screen.

    Dig around in the documentation and you’ll find the autoresizing mask that works best for your situation.

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

Sidebar

Related Questions

I want to create some up and down buttons using the standard button background
I'm trying to create Command Buttons dynamically, but clicking the button in question doesn't
I want to create some UIbutton dynamically. And display the tag number. So I
I'm trying to create some modal windows that load in their content dynamically using
I need to dynamically create some views in my app and place some buttons
I would like to create some buttons with dynamic width using CSS sprites and
I used glade to create some gtk buttons. is it possible to add an
I create a flash interface for CD that contains some buttons that open some
I wrote some CSS in my HTML code to create rollover buttons. Then i
I've got some dynamic created buttons in my GridView (adding them OnDataBound), but when

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.