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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:33:31+00:00 2026-05-26T17:33:31+00:00

In iOS5 , it seems the width of a UISwitch has changed from 94px

  • 0

In iOS5, it seems the width of a UISwitch has changed from 94px to 79px. I use the width of that component to calculate how for to the right, to place it in a UITableViewCell.

Is there a way to ask, through the iOS API, what the width of a UISwitch is, WITHOUT adding it to a view yet?

My current thoughts are to keep the two widths I already know in defines, and then check against iOS version, and if >=5 it should be 79px. But that won’t work as well if the width of that component changes again sometime.

  • 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-26T17:33:31+00:00Added an answer on May 26, 2026 at 5:33 pm

    Yes, because a UISwitch is a control of fixed width and sets and determines its own size, you can simply create it using CGRectZero and then check its dimensions via its frame. This works in iOS4 and iOS5.

    On iOS 4 you get a width of 94px and on iOS 5 you will get the width of 79px. You do this like so:

    UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
    width = mySwitch.frame.size.width;
    

    You can then use the width value to position accordingly in the parent view. Do that by setting the desired x,y position on the UISwitch frame.

    Also I suggest you DO set AutoResizingMask margin values on the UISwitch so that it remains in the position you place it regardless of device orientation or type.

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

Sidebar

Related Questions

I'm working on a component that is a subclass from UIView and contains a
In IOS5, with storyboards, suppose you have a UISplitViewController, which has some views that
info: iOS5, xcode4.3.2, iphone5 Create tab view controller application from xcode template wizard. Following
I have a little iOS5 app that shows images. I click on the image
Is there any component or API for IOS5 to easy implement a horizontal slide
In an iPhone app for iOS5 I'm trying to create a controller object that
What is the correct way to use CMAttitude:multiplyByInverseOfAttitude? Assuming an iOS5 device laying flat
I'm updating my app to use xCode 4, iOS5 and the latest Facebook SDK.
I'm trying to tweet an image from an iOS5 app with code like this:
From what I've read, this topic has come up several times over the last

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.