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

  • Home
  • SEARCH
  • 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 9139187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:21:18+00:00 2026-06-17T09:21:18+00:00

This seems such a simple thing, I can’t understand why it’s going wrong. I’m

  • 0

This seems such a simple thing, I can’t understand why it’s going wrong. I’m trying to change the size of a UIButton from the touchUpInside handler of another. To repro, I’ve created a new (iOS 6) project in Xcode, and dragged two buttons to the xib file that’s created by default. The touchUpInside handler for button1 is shown below. If I just include the statement that sets the origin.x of button2, I see button2 move as expected. However, the statement that sets the size.width of the button doesn’t work. In fact, if I include that statement the origin doesn’t change either.

I can resize the button fine in the xib designer and the only property I’ve set (other than

- (IBAction)buttonPressed:(id)sender {
    CGRect f = self.button2.frame;
    f.origin.x += 10;
    // this doesn't work, including it prevents even the origin change from working
    f.size.width += 10; 
    self.button2.frame = f;
}

How can I successfully change the size of the button?

Thanks!

  • 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-17T09:21:19+00:00Added an answer on June 17, 2026 at 9:21 am

    For sure you are using AutoLayout, simply what happen here is iOS AutoLayout mechanism tries to set your layout automatically. try your code by turning off AutoLayout. hope you know how to turn off the auto layout in xcode, if not let me know.

    Happy coding!!!

    EDIT:

    AutoLayout comes with iOS 6, thats why your code worked with older version(iOS 5). btw as Nick said you can turn off AutoLayout in the file inspector in the xcode.

    See attached screenshot.

    enter image description here

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

Sidebar

Related Questions

This seems like such a simple thing but I just can't get it to
This is driving me absolutely bonkers, and it seems like such a simple thing
This seems like a simple thing, but I can't find an answer in the
It seems like such a simple thing, but I can't find any obvious solutions...
This seems like such a trivial thing but I can’t for the life of
I apologize because this seems like such a simple thing. What's the correct way
I'm a little embarrassed to ask this. It seems like such a simple thing.
This seems like such a simple issue but I cannot find an elegant solution.
This seems like such a simple question. I have several Edit boxes on my
This seems like such an obvious thing that excel must have this feature, I

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.