uiswitch

UISwitch - change from on/off to yes/no

耗尽温柔 提交于 2019-12-02 17:37:49
does anyone know of a way I can change the text label for on and off to yes and no. I did it with ((UILabel *)[[[[[[switchControl subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:0]).text = @"Yes"; ((UILabel *)[[[[[[switchControl subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:1]).text = @"No"; However, with the release of iOS 4.2, this is no longer supported (this probably wasn't recommended by Apple anyway) My client is insisting on yes/no switches. I'd appreciate any advice! many thanks Vladimir You need to implement your custom UISwitch for

iPhone: Save boolean into Core Data

这一生的挚爱 提交于 2019-12-02 14:11:58
I have set up one of my core data attributes as a Boolean. Now, I need to set it, but XCode keeps telling me that it may not respond to setUseGPS. [ride setUseGPS: useGPS.on]; What is the method for setting a boolean in core data? All my other attributes are set this way, and they work great. So, not sure why a boolean does not work to be set this way? Core Data "does not have" a Boolean type (it does, but it is an NSNumber). So to set the equivalent of useGPS = YES. [entity setUseGPS:[NSNumber numberWithBool:YES]]; And the other way around: BOOL isGPSOn = [[entity useGPS] boolValue]; Update:

Using NSUserDefaults for storing UISwitch state

北慕城南 提交于 2019-12-02 11:42:14
问题 I am trying to persist the UISwitch state in my settings view of my application. Basically it is a UITableView and contains a few switches to get the user preferences. The below code explains how the switches are constructed (only one switch construct is given below, others are also constructed the sameway). if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SomeIdentifierB] autorelease]; if (syncStartupSwitch) { syncSwitch.on = YES; }else {

Why UISwitch onImage/offImage properties are not working on iOS 7?

陌路散爱 提交于 2019-12-02 06:55:52
问题 Whats the point of having these two options/properties and deprecate them? From Apple docs: offImage The image displayed while the switch is in the off position. @property(nonatomic, retain) UIImage *offImage Discussion In iOS 7, this property has no effect. In iOS 6, this image represents the interior contents of the switch. The image you specify is composited with the switch’s rounded bezel and thumb to create the final appearance. Availability Available in iOS 6.0 and later. Declared In

Using NSUserDefaults for storing UISwitch state

爱⌒轻易说出口 提交于 2019-12-02 04:47:42
I am trying to persist the UISwitch state in my settings view of my application. Basically it is a UITableView and contains a few switches to get the user preferences. The below code explains how the switches are constructed (only one switch construct is given below, others are also constructed the sameway). if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SomeIdentifierB] autorelease]; if (syncStartupSwitch) { syncSwitch.on = YES; }else { syncSwitch.on = NO; } [syncSwitch addTarget:self action:@selector(syncAtStartup:) forControlEvents

Why UISwitch onImage/offImage properties are not working on iOS 7?

风流意气都作罢 提交于 2019-12-02 03:50:01
Whats the point of having these two options/properties and deprecate them? From Apple docs: offImage The image displayed while the switch is in the off position. @property(nonatomic, retain) UIImage *offImage Discussion In iOS 7, this property has no effect. In iOS 6, this image represents the interior contents of the switch. The image you specify is composited with the switch’s rounded bezel and thumb to create the final appearance. Availability Available in iOS 6.0 and later. Declared In UISwitch.h What should I do now? Replace all UISwitches with UIButtons? Use UIButton's selected property

UISwitch Doesn't Send valueChanged Event When Changed Programmatically

妖精的绣舞 提交于 2019-12-01 17:46:31
I have a pair of UISwitches hooked up to a IBAction via the valueChanged event. The valueChanged event is firing fine when the switches are touched. However, if I change one of the switches programmatically it doesn't call my IBAction. - (IBAction)switchChanged:(UISwitch *)sender { if (sender == self.shippingSwitch) { if (self.shippingSwitch.on && !self.PayPalSwitch.on) { [self.PayPalSwitch setOn:YES animated:YES]; } } if (sender == self.PayPalSwitch) { if (!self.PayPalSwitch.on) { // This is not working when the PayPal switch is set via the code above self.PayPalEmailField.backgroundColor =

Customize uiswitch image properly?

断了今生、忘了曾经 提交于 2019-12-01 06:32:14
I have an UISwitch in my iOS 6 app, that's on and off image is customised. self.testSwitch.onImage = [UIImage imageNamed:@"on"]; self.testSwitch.offImage = [UIImage imageNamed:@"off"]; I use 77 points wide and 22 points tall image for this purpose (154x44 in retina), as it is stated in the documentation. But my image does not fit to my uiswitch, it seems ugly, the default style hides my one, like on the attached image. What should I set to make it work in a proper way? tobs Apple doesn't have an Appearance API for UISwitch . You can set a tint color property ( onTintColor ). But that's not

How do I retrieve UITableView row number of a UISwitch?

时光怂恿深爱的人放手 提交于 2019-12-01 05:54:51
I have tried several approaches posted here, but I cannot get my table full of switches to return an index value for the cell of the changed switch. I am creating the view containing the table programmatically (no xib). TableSandboxAppDelegate.m I instantiate the view controller in didFinishLaunchingWithOptions: with: ... TableSandboxViewController *sandboxViewController = [[TableSandboxViewController alloc] init]; [[self window] setRootViewController:sandboxViewController]; ... TableViewController.h file reads: @interface TableSandboxViewController : UITableViewController { NSMutableArray *

UISwitch set on/off Image

二次信任 提交于 2019-11-30 20:02:48
I want to set my Switch like this: But I try in ios9 , it does not work. I saw in apple UISwitch Class Reference. It says that : Discussion In iOS 7, this property has no effect. How about iOS 9? Any one success? My Code: switch1 = UISwitch(frame:CGRectMake(self.view.frame.width/2 - 20, 400, 10, 100)) switch1.on = true switch1.onTintColor = UIColor.lightGrayColor() switch1.tintColor = UIColor.greenColor() switch1.thumbTintColor = UIColor.blackColor() //set on/off image switch1.onImage = UIImage(named: "on-switch") switch1.offImage = UIImage(named: "off-switch") Use a UIButton instead. let