FAQ Database Discussion Community


Update the state of a UISwitch when pressed in a TableView

ios,uitableview,swift,uiswitch
I have an iOS application that needs to turn on/off lights remotely. The app gets the data for the lights from parse.com and builds a tableview with every individual cell showing the name of the light and a UISwitch. I want to know how to change the boolean value stored...

Swift - UISwitch as selector between two values?

swift,uiswitch
I want as an option in an app I'm building to offer the user to select between seeing temperatures in Celsius (C) or Fahrenheit (F). This option will be shown within a tableview controller. My initial thought was to use an UISwitch for this but this would require adding labels...

Saving username and password using UISwitch in Swift

swift,passwords,nsuserdefaults,username,uiswitch
Ive searched a lot of threads and this is my last resort because Ive seen this question asked different ways but not exactly for swift and for Username and password saving. I want my UISwitch when turned on to save my username and password info. I've been trying all day...

Uiswitch does not change the state ios

ios,uiswitch
I have a problem with my UISwitch. When I select or deselect my switch state(isHighlighted, selected) is always 0. I'm using iOS 8.3. - (IBAction)sliderOnOff:(id)sender { NSLog(@"%lu", (unsigned long)_sliderOnOff.state); } Log : 2015-04-27 22:41:50.617 Project[4011:179116] 0 2015-04-27 22:41:50.762 Project[4011:179116] 0 2015-04-27 22:41:50.972 Project[4011:179116] 0 2015-04-27 22:41:51.088 Project[4011:179116] 0 2015-04-27 22:41:51.226...

Swift: Problems with PrototypeCells in UITableViewController

ios,swift,tableview,uiswitch
I have a problem with my iOS Application. I'm using Swift and XCode 6.3. I have a UITableViewController in my application and in this TableView I've created a prototype cell (Custom). In the design it looks like this: This is how I want the cells (left the title and on...

Weird looking UISwitch in UITableViewCell

ios,uitableview,uiswitch
I added a UISwitch as a subview to the contentView of a UITableViewCell and set isOn to be true. After toggling it, it becomes the following and looks weird. Does anyone know why this might happen and how to solve this problem? Weird UISwitch: https://dl.dropboxusercontent.com/u/43497092/stackOverflow/Screen%20Shot%202015-06-12%20at%209.28.43%20AM.png For comparison, a normal looking...

Unchecking a switch depending on user decision

ios,objective-c,uialertview,uilocalnotification,uiswitch
I'm building an app that asks the user for permission to post notifications when the user enables a switch. I'm using this code: - (IBAction)mySwitchValueChanged:(id)sender { if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){ [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]]; // ask the user for permission } if ([[UIApplication...

How can I create this Switch behavior?

ios,uibutton,uistoryboard,uiswitch
I want to create the following selection button to pick from the two options "Salary" and "Hourly Wage". I have images for when either (left or right) option are selected. What UI element in iOS can I use to create this? Looked into a Switch but did not see an...

How do i keep UISwitch state when changing ViewControllers?

ios,swift,state,uiswitch
When I move from one view controller to another, the switch on the first controller resets itself and does not retain its state. How can I make it save its state when come back to it after viewing other controllers? And how do I make it save its state after...

Using switches inside static tableview

ios,uitableview,swift,uiswitch
I have a static tableview for settings. I have switches inside this tableview. But I don't know how to access to switches from code. I mean how can I get the switch on/off status in code ? View: I have one view controller for settings but I couldn't drag from...

Turn a switch Off or On on the basis of another switch state

ios,xcode,uiswitch
How can I turn a switch off inside a different switch? Here's an example - When the isMale switch is turned on, turn off the isFemale switch. - (IBAction)isMale:(id)sender { if ([sender isOn]) { //TURN isFemale SWITCH OFF } else { ... } } and - (IBAction)isFemale:(id)sender { if ([sender...

Cancel auto triggering value changed event for UISwitch

ios,swift,xamarin,uikit,uiswitch
Is it possible to cancel auto triggering value changed event for UISwitch? I have action of touch up inside event for the UISwitch, I wanna do background job first and then when job is done, i manually turn the switch on instead of it turns itself on immediately after touch...

UISwitch is not visible in UITableview(iOS 8)?

ios,uitableview,uiswitch
I have created a UISwitch in UITableview but it is not visible in the exact row.Code which i referred and implemented in my project.Can anyone tell me how to correct it. if (indexPath.row == 1) { UISwitch *switchBtn = [[UISwitch alloc] initWithFrame:CGRectMake(200, 10, 150, 50)]; [switchBtn setOn:YES animated:YES]; NSInteger row;...

Swift, Xcode - Increasing the size of a UISwitch

xcode,swift,size,uiswitch
I am making my app 'universal' (used on iPhone and iPad) and I have found ways of increasing the size of everything except for UISwitches. Is there a way of doing so? Any help is greatly appreciated....