UISwitch & App Store User Approval

After some reading, I found that you can customize the text and color in the UISwitch control. I am wondering if these methods will cause problems with trying to get approval from my application and enable it in the App Store.

Sample code taken from Cookbook sample code for iPhone developers :

// Custom font, color switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero]; [switchView setCenter:CGPointMake(160.0f,260.0f)]; [switchView setLeftLabelText: @"Foo"]; [switchView setRightLabelText: @"Bar"]; [[switchView rightLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]]; [[switchView leftLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]]; [[switchView leftLabel] setTextColor:[UIColor yellowColor]]; 
+49
objective-c iphone
Mar 29 '09 at 15:50
source share
8 answers

this will not create problems with sending to the application store. You can use custom controls or modified versions of the built-in controls until you use any private (undocumented) APIs to create / modify these widgets.

+40
Mar 29 '09 at 16:21
source share
— -

You may like my custom switch implementation (open source and free to use) ... it allows you to configure the switch to display any text or easily subclass it to draw your own images in the track .... http: //osiris.laya .com / projects / rcswitch /

This switch makes it easier to draw an image instead of text: subclass the class of the main switch and override a drawing method like this, and your image will be automatically animated:

 - (void)drawUnderlayersInRect:(CGRect)aRect withOffset:(float)offset inTrackWidth:(float)trackWidth { [onImage drawAtPoint:CGPointMake(floorf(aRect.origin.x + 13 + (offset - trackWidth)), floorf((self.bounds.size.height - onImage.size.height) / 2.0))]; [offImage drawAtPoint:CGPointMake(floorf(aRect.origin.x + 15.0 + (offset + trackWidth)), ceilf((self.bounds.size.height - offImage.size.height) / 2.0))]; } 
+16
Apr 30 '10 at 1:21
source share

Take a look at the UISwitch user control that I created to allow me to change the background color of the control. You can use the same method to very easily change text, font or text color.

uiswitch user control

The code is available on Github and includes a PSD, which is used to create three different png files that the control uses. You can modify the contents of psd to recreate png files in any format. Change them to control and go through.

+7
Nov 13 '09 at 14:07
source share

I just created this view and saw that you doubt

hope this helps

.h file:

 #import <UIKit/UIKit.h> @interface EDSwitch : UIView { UIButton* onButton,*offButton; UIImageView* bg; } - (id)initWithText:(NSString*)on andText:(NSString*)off andDelegate:(id)delegate andOnSelector:(SEL)onSelector andOffSelector:(SEL)offSelector andBackgroundImage:(UIImage*)bgImage andStartingValue:(BOOL)b; @end 

and .m file:

 #import "EDSwitch.h" @implementation EDSwitch - (id)initWithText:(NSString*)on andText:(NSString*)off andDelegate:(id)delegate andOnSelector:(SEL)onSelector andOffSelector:(SEL)offSelector andBackgroundImage: (UIImage*)bgImage andStartingValue:(BOOL)b { self = [super initWithFrame:CGRectZero]; if (self) { UILabel* onLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, 8, 50, 20)]; onLabel.text = on ; onLabel.tag = 1; onLabel.font = [UIFont fontWithName:kCalibri size:15]; onLabel.textAlignment = UITextAlignmentCenter; onLabel.textColor = [UIColor colorFromHexString:@"#009dd0"]; onLabel.backgroundColor = [UIColor clearColor]; [onLabel sizeToFit]; [onLabel setWidth:onLabel.frame.size.width + 4]; UILabel* offLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, 8, 50, 20)]; offLabel.text = off ; offLabel.tag = 1; offLabel.textAlignment = UITextAlignmentCenter; offLabel.font = [UIFont fontWithName:kCalibri size:15]; offLabel.textColor = [UIColor colorFromHexString:@"#009dd0"]; offLabel.backgroundColor = [UIColor clearColor]; [offLabel sizeToFit]; [offLabel setWidth:offLabel.frame.size.width + 4]; float high = MAX([offLabel.text sizeWithFont:offLabel.font].width,[onLabel.text sizeWithFont:onLabel.font].width) + 10; onButton = [UIButton buttonWithType:UIButtonTypeCustom]; [onButton addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventTouchUpInside]; [onButton addTarget:delegate action:onSelector forControlEvents:UIControlEventTouchUpInside]; offButton = [UIButton buttonWithType:UIButtonTypeCustom]; [offButton addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventTouchUpInside]; [offButton addTarget:delegate action:offSelector forControlEvents:UIControlEventTouchUpInside]; [onButton setWidth:high]; [onButton setX:0]; [onButton addSubview:onLabel]; [onLabel setWidth:high]; [onLabel setX:0]; [offButton setWidth:high]; [offButton addSubview:offLabel]; [offButton setX:high]; [offLabel setWidth:high]; [offLabel setX:0]; bg = [[UIImageView alloc] initWithImage:bgImage]; self.frame = CGRectMake(200, 200 , (high*2), 34); self.layer.borderColor = [[[UIColor colorFromHexString:@"#009dd0"] colorWithAlphaComponent:0.5] CGColor]; self.layer.borderWidth = 0.5; self.layer.cornerRadius = 5; [self setX:[UIApplication sharedApplication].keyWindow.frame.size.width - self.frame.size.width - 8]; [self addSubview:bg]; [bg setWidth:[self getWidth]]; [bg setHeight:[self getHeight]]; [self addSubview:onButton]; [self addSubview:offButton]; [onButton setHeight:[self getHeight]]; [offButton setHeight:[self getHeight]]; if(b){ [onButton setBackgroundColor:[UIColor clearColor]]; [offButton setBackgroundColor:[UIColor whiteColor]]; } else{ [onButton setBackgroundColor:[UIColor whiteColor]]; [offButton setBackgroundColor:[UIColor clearColor]]; } } return self; } -(void)toggled:(UIButton*)sender{ if(sender == onButton){ UILabel* l = (UILabel*)[onButton viewWithTag:1]; l.textColor = [UIColor grayColor]; [onButton setBackgroundColor:[UIColor clearColor]]; l = (UILabel*)[offButton viewWithTag:1]; l.textColor = [UIColor colorFromHexString:@"#009dd0"]; [offButton setBackgroundColor:[UIColor whiteColor]]; } else{ UILabel* l = (UILabel*)[offButton viewWithTag:1]; l.textColor = [UIColor grayColor]; [offButton setBackgroundColor:[UIColor clearColor]]; l = (UILabel*)[onButton viewWithTag:1]; l.textColor = [UIColor colorFromHexString:@"#009dd0"]; [onButton setBackgroundColor:[UIColor whiteColor]]; } } @end 

using:

  [[UIApplication sharedApplication].keyWindow addSubview:[[EDSwitch alloc] initWithText:@"aksdjaksdjh" andText:@"dasjdsaj" andDelegate:self andOnSelector:@selector(logon) andOffSelector:@selector(logoff) andBackgroundImage:[UIImage imageNamed:@"toggleBottom.png"] andStartingValue:YES]]; 

live long and prosper

eiran

+1
Mar 16 '13 at 20:07
source share

In the Apple Human Interface Guide, in the Switch documentation, Apple states:

Use the switch in the row of the table to give users two simple, diametrically opposite options that determine the state of something, for example, yes / no or on / off. Use a predictable value pair so that users do not have to move the control to find out what the other value is.

So yes, it is great to change the text while you use a predictable pair of values ​​(e.g. yes / no).

0
Oct 13 '11 at 8:30
source share

No need to subclass UISwitch. A fairly simple solution that I implemented is a subclass of UIView and on a touch event switched between two images (ON / OFF) with a slide transition that is everything.

Relations Dhanesh

0
May 8 '12 at 5:35
source share

From the Apple documentation: -

You use the UISwitch class to create and manage the on / off buttons, see, for example, in the (Settings) settings for services such as Air mode. These objects are called switches.

The UISwitch class declares a property and method to control its on / off. As in the case of UISlider, when the user manipulates the control switch ("flips" it), the UIControlEventValueChanged event is generated, as a result of which the control (if configured correctly) sends an action message.

The UISwitch class is not configurable.

Apple states that they are not configurable, which may mean rejection of your application.

-one
Sep 18 '11 at 18:36
source share

This will cause approval issues for your application. ask me how do I know: P

Apple recently got an unpleasant note from Apple. We are in the process of finding alternatives.

-thirty
May 21 '09 at 18:13
source share



All Articles