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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:31:55+00:00 2026-05-15T14:31:55+00:00

The UISwitch on my device: Switch Image with the bottom pixels cut off http://gorgando.com/uiswitch.jpg

  • 0

The UISwitch on my device: Switch Image with the bottom pixels cut off http://gorgando.com/uiswitch.jpg

The UISwitch on the simulator: Good UISwitch http://gorgando.com/uiswitch-good.png

As you can see, the bottom pixels are cut off on the device, but not on the simulator. I have tried just about everything I can think of, but nothing has fixed the problem.

Some of the things I’ve tried:

  • Changing the UISwitch’s frame’s height
  • Changing the UICell’s height
  • Changing the UICell’s contentView’s height
  • Adding the UISwitch to the UICell rather than the UICell’s contentView

Here is the relevant code:
This is in the viewDidLoad of the uiTableViewController:

UISwitch *sw =  [[UISwitch alloc] init];
self.contactedSwitch = sw;
[sw release];
self.contactedSwitch = [UISwitch switchWithLeftText:@"YES" andRight:@"NO"];
self.contactedSwitch.center = CGPointMake(230, 22);
self.contactedSwitch.on = [self.contact.contacted boolValue];

This is where the switchWithLeftText:andRight method comes from:

#import "UISwitch-Extended.h"

#define TAG_OFFSET  900

@implementation UISwitch (tagged)
- (void) spelunkAndTag: (UIView *) aView withCount:(int *) count
{
    for (UIView *subview in [aView subviews])
    {
        if ([subview isKindOfClass:[UILabel class]])
        {
            *count += 1;
            [subview setTag:(TAG_OFFSET + *count)];
        }
        else 
            [self spelunkAndTag:subview withCount:count];
    }
}

- (UILabel *) label1 
{ 
    return (UILabel *) [self viewWithTag:TAG_OFFSET + 1]; 
}

- (UILabel *) label2 
{ 
    return (UILabel *) [self viewWithTag:TAG_OFFSET + 2]; 
}

+ (UISwitch *) switchWithLeftText: (NSString *) tag1 andRight: (NSString *) tag2
{
    UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 94, 27)];

    int labelCount = 0;
    [switchView spelunkAndTag:switchView withCount:&labelCount];

    if (labelCount == 2)
    {
        [switchView.label1 setText:tag1];
        [switchView.label2 setText:tag2];
    }

    return [switchView autorelease];
}

@end

This is where I add the UISwitch to my tableviewcell:

[[contactedCell contentView] addSubview:self.contactedSwitch];

Thanks so much!

[Update] I thought the tableviewcell’s might be the problem, so I added these UISwitches to a regular UIView to see how they looked. I have the exact same problem where they look alright in the simulator and the bottom is chopped in the device. So bizarre!

  • 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-15T14:31:55+00:00Added an answer on May 15, 2026 at 2:31 pm

    Never figured out exactly what was wrong, but I ended up creating the UISwitches in IB and got it to work beautifully that way. Very weird that it works in IB and not programmatically when I am basically doing the exact same thing.

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

Sidebar

Related Questions

I have a problem with UISwitch repositioning on device rotation. the switch is part
UISwitch text shows ON/OFF in English. When I switch language to Japanese, UISwitch shows
I'm using a UISwitch-Component at the bottom of a view that sits within a
I have a screen with several UISwitch controls. On my iPhone simulator this screen
How can I add UISwitch(toggle switch) to UIToolBar without using InterfaceBuilder ? It is
I have two UISwitch....and i need to turn off the first one when the
I am using UISwitch in iOS 3 to make a switch element in my
I have a tableview with UISwitch in each row of the table. Switch is
I have made a game which has a UISwitch that turns the music off.
I am trying to detect when a UISwitch it on / off // .h

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.