Questions tagged [uiswitch]

You use the UISwitch class to create and manage the On/Off buttons which can be seen in iOS, for example, in the preferences (Settings) for such services as Airplane Mode. These objects are known as switches. The UISwitch class declares a property and a method to control its on/off state. As with UISlider, when the user manipulates the switch control a UIControlEventValueChanged event is generated, which results in the control sending an action message.

A UISwitch lets the user turn an option on and off in iOS. UISwitches used throughout the Settings app to let a user quickly toggle a specific setting.

Switches do not need a delegate to function properly; their parent view controller can define their behavior without implementing any delegate protocols.

You can customize the appearance of the switch by changing the color used to tint the switch when it is on or off.

Reference Link : UISwitch Document

For more information about appearance and behavior configuration, see Switches

954 questions
128
votes
19 answers

Change color of UISwitch in "off" state

I've learned that we can change the UISwitch button appearance in its "on" state, but is it also possible to change the color of the UISwitch in the "off" state?
user198725878
  • 6,266
  • 18
  • 77
  • 135
105
votes
3 answers

What does "invalid mode 'kCFRunLoopCommonModes' ..."mean?

Environment: Version 11.0 beta 3 (11M362v) Here's the full text: invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per…
Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105
93
votes
12 answers

iOS7 UISwitch its Event ValueChanged: Calling continuously is this Bug or what..?

Edit It's now fixed on ios7.1 Don't do any tweak to fix it. Edit2 Apparently the same problem happens again in iOS 8.0 and 8.1 Edit3 It's now fixed on ios9.2 Don't do any tweak to fix it. Hi Today i seen in UISwitch's Event ValueChanged: Calling…
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
83
votes
6 answers

UISwitch in a UITableView cell

How can I embed a UISwitch on a UITableView cell? Examples can be seen in the settings menu. My current solution: UISwitch *mySwitch = [[[UISwitch alloc] init] autorelease]; cell.accessoryView = mySwitch;
testing
  • 19,681
  • 50
  • 236
  • 417
62
votes
4 answers

iPhone UIButton with UISwitch functionality

Is there either a way to implement UISwitch with custom graphics for the switch-states? Or as an alternative the other way round, an UIButton with UISwitch functionality?
scud
  • 1,147
  • 1
  • 14
  • 25
59
votes
3 answers

How to call an action when UISwitch changes state?

I want to perform some action when UISwitch changes its state, thus is set on or off. How do I do this? I need to pass two objects as parameters. It's created in code, thus not using xib.
Ondrej
  • 1,610
  • 3
  • 19
  • 34
54
votes
10 answers

Swift - How to set initial value for NSUserDefaults

I have a switch called soundSwitch, I'm saving the state of the button using an userDefault as such: @IBAction func soundsChanged(sender: AnyObject) { if soundSwitch.on{ defaults.setBool(true, forKey: "SoundActive") …
Big Green Alligator
  • 1,175
  • 3
  • 17
  • 33
53
votes
4 answers

iPhone: Save boolean into Core Data

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…
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
47
votes
7 answers

Swift/UISwitch: how to implement a delegate/listener

In my UITableViewController I have a custom cell which contains a switcher which is the following: import Foundation import UIKit class SwitchCell: UITableViewCell { @IBOutlet weak var label : UILabel! @IBOutlet weak var switchEmail :…
SagittariusA
  • 5,289
  • 15
  • 73
  • 127
39
votes
10 answers

How to know the UITableview row number

I have a UITableViewCell with UISwitch as accessoryview of each cell. When I change the value of the switch in a cell, how can I know in which row the switch is? I need the row number in the switch value changed event.
Jean Paul
  • 2,389
  • 5
  • 27
  • 37
38
votes
7 answers

Changing UISwitch width and height

I am trying to change the default height and width of a UISwitch element in iOS, but unsuccessfully. Can you change the default height and width of a UISwitch element? Should the element be created programmatically?
Bharat Raichur
  • 425
  • 1
  • 4
  • 8
34
votes
5 answers

How to create a UITableViewCell with a UISwitch and get the data?

I have a simple problem. I created a custom UITableViewCell that includes a UISwitch in Interface Builder. Question 1: Easier, better way to do it ? Question 2: When used in an UITableViewController, what would be the best way to get the data ? At…
eemceebee
  • 2,656
  • 9
  • 39
  • 49
30
votes
2 answers

Creating a UISwitch Programmatically

In a seemingly never ending effort to learn more about iphone development, I have been playing around with some of the source code available through apples developer website. The particular example I am working with is Core Data Books, found here.…
Steve
  • 628
  • 1
  • 10
  • 18
27
votes
4 answers

Custom UISwitch with image

I need to implement a custom switch in a project. Currently what I have found is that we cannot alter with UISwitch in way to implement as shown in below image. I've followed posts and googled through stackoverflow and other blogs but didn't found a…
Arshad Parwez
  • 1,563
  • 2
  • 19
  • 29
25
votes
8 answers

Detecting a change in UISwitch

This sounds trivial but I'm noticing some weirdness. I've wired up a handler for the Value Changed event of a UISwitch. What I would expect is that each time the handler is called the value of the switch would change. But that's actually not always…
John
  • 287
  • 1
  • 4
  • 7
1
2 3
63 64