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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:34:52+00:00 2026-05-28T05:34:52+00:00

I have a UIButton which i add programmatically. No problems here, it stetches as

  • 0

I have a UIButton which i add programmatically. No problems here, it stetches as it should and looks good.
However, when I tilt the phone to landscape the button gets out of place, and I want it still centered.

Portrait:
It's centered here

Landscape:
Not centered here

I have tried a bunch of thing but cannot seem to get it working, it seems to me that the autoresizing should take care of it, however… it doesn’t work in that case.

- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 49)];

    _notMeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *butImage = [[UIImage imageNamed:@"notme.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:6];
    UIImage *butImagePressed = [[UIImage imageNamed:@"KC_notmePressed.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:6];
    [_notMeButton setBackgroundImage:butImage forState:UIControlStateNormal];
    [_notMeButton setBackgroundImage:butImagePressed forState:UIControlStateHighlighted];
    [_notMeButton setTitle:NSLocalizedString(@"Change address", @"KlarnaCheckout") forState:UIControlStateNormal];
    [_notMeButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [_notMeButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    [_notMeButton setTitleShadowColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_notMeButton.titleLabel setShadowColor:[UIColor whiteColor]];
    [_notMeButton.titleLabel setShadowOffset:CGSizeMake(0, 1)];
    [_notMeButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [_notMeButton addTarget:self action:@selector(thisIsNotMe) forControlEvents:UIControlEventTouchUpInside];
    [_notMeButton setTag:1];
    [_notMeButton sizeToFit];
    [_notMeButton setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
    [_notMeButton setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
    [_notMeButton setFrame:CGRectMake(10, 10, _notMeButton.frame.size.width+20, _notMeButton.frame.size.height)];
    [_notMeButton setCenter:footerView.center];

    [footerView addSubview:_notMeButton];

    return footerView;
}
  • 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-28T05:34:53+00:00Added an answer on May 28, 2026 at 5:34 am

    Your idea about autoresizing mask is right, but you’re setting it incorrectly:

    [_notMeButton setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
    [_notMeButton setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
    

    The second line overwrites what you set in the 1st. Correct way to set several flags will be:

    [_notMeButton setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIButton which the user clicks on to bring up a UIImagePickerController
I am trying to add an image to the UIBarButtonItem which I have to
I have an UIButton bn and an UIActivityIndicator ai which is above the button
I have a view controller, MainViewController in which I have a UIButton as an
I have the following code which tries to add a accessory view, but I
I have a UIPickerView which works correctly, now I want to add a button
I have created a custom button called ModuleUIButton which inherits from UIButton . This
I have three rows which are configured programmatically. I want to place an image
I have a CCLayer which I need to add a camera to, on top
I have a UINavigationController which I add a subview to. [masterNavigationController.view addSubview:footerViewController.view]; The problem

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.