uiswitch

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

﹥>﹥吖頭↗ 提交于 2019-11-28 17:28:52
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 some point I either need to go through the table and check every cell about the status OR send some feedback when the status of the switches changes directly ? Thanks for the help. You could just add the UISwitch in your accessory view. That is the easiest way to do it, not to mention that it looks 'elegant'. Then, in your tableview controller code,

Adding dark mode to iOS app

你说的曾经没有我的故事 提交于 2019-11-28 17:06:51
I am trying to add a theme to my app (a dark theme). So when the user clicks an activity switch it would then make the whole app go into the dark mode. I have hard coded the dark mode just to see what it would look like; however now I would like to be able to enable and disable it through and UISwitch, but I am not sure how to do this? class DarkModeTableViewCell: UITableViewCell { var DarkisOn = Bool() let userDefaults = UserDefaults.standard @IBOutlet var darkModeSwitchOutlet: UISwitch! override func awakeFromNib() { super.awakeFromNib() } override func setSelected(_ selected: Bool, animated

UISwitch in accessory view of a tableviewcell, passing a parameter with the selector to have selector function see the indexpath.row?

六月ゝ 毕业季﹏ 提交于 2019-11-28 14:06:18
I have a UISwitch in a tableviewcontroller, and when the switch is toggled I want it to change the value of a boolean variable in an array I created inside the view controller, that the cell is related to. Kind of like the Stock Alarm App on IOS, where each cell has a UISwitch , and toggling the switch will turn off each individual alarm. So with the UISwitch , with its selector code, this is inside the cellForRowAtIndexPath method //switch let lightSwitch = UISwitch(frame: CGRectZero) as UISwitch lightSwitch.on = false lightSwitch.addTarget(self, action: #selector(switchTriggered),

Changing of UISwitch text in iOS 4.2

*爱你&永不变心* 提交于 2019-11-28 13:56:27
I am trying to change the text in UISwitch. The sample from the website ( Changing the text on a UISwitch ) works fine but when I upgrade my xcode to 3.2.5 and iOS 4.2, the application crash when the functions is being called to change the text. I am using the following example from the website. eg. ((UILabel *)[[[[[[_agreeAgb subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:0]).text = @"Foo"; ((UILabel *)[[[[[[_agreeAgb subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:1]).text = @"Bar"; The exception thrown is because null object is encountered.

Cannot convert value of type 'NSObject -> () -> PostFeed' to expected argument type 'AnyObject?'

北慕城南 提交于 2019-11-28 05:44:32
问题 I'm adding a UISwitch in the following way: let anonSwitch : UISwitch = { let mySwitch = UISwitch() mySwitch.on = false mySwitch.setOn(false, animated: false); mySwitch.tintColor = UIColor(red: (69/255.0), green: (209/255.0), blue: (153/255.0), alpha: 1.0) mySwitch.addTarget(self, action: #selector(handleAnonSwitch), forControlEvents: .ValueChanged) return mySwitch }() Now I'm getting the following error message on the self keyword in mySwitch.addTarget : Cannot convert value of type

Handling multiple UISwitch controls in a table view without using tag property

痴心易碎 提交于 2019-11-28 04:04:48
问题 I have a table view controller with multiple UISwitch controls in them. I set the delegate to the table view controller with the same action for all switches. I need to be able to determine what switch was changed, so I create an array of strings that contains the name of each switch. The indexes in the array will be put in the tag property of each UISwitch. However, I'm ready using the tag property for something else, namely to find the right control in the cell in cellForRowAtIndexPath with

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

南楼画角 提交于 2019-11-27 20:07:31
问题 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 some point I either need to go through the table and check every cell about the status OR send some feedback when the status of the switches changes directly ? Thanks for the help. 回答1: You could just add the UISwitch in your accessory view. That is

Change color of UISwitch in “off” state

与世无争的帅哥 提交于 2019-11-27 17:34:26
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? Try using this yourSwitch.backgroundColor = [UIColor whiteColor]; youSwitch.layer.cornerRadius = 16.0; All thanks to @Barry Wyckoff. Long Pham My solution with #swift2: let onColor = _your_on_state_color let offColor = _your_off_state_color let mSwitch = UISwitch(frame: CGRectZero) mSwitch.on = true /*For on state*/ mSwitch.onTintColor = onColor /*For off state*/ mSwitch.tintColor = offColor mSwitch.layer.cornerRadius = mSwitch.frame

Detecting if music is playing?

柔情痞子 提交于 2019-11-27 14:08:11
问题 My app involves music(iPodMusic), and there is a UISwitch toggling play/pause. My goal is to be able to detect if music is playing, so that therefore the play/pause switch can say 'play' when music is playing and 'pause' if it isn't. 回答1: if ([[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying) ... 回答2: If the music is from your own app, check AVAudioPlayer's playing property. If the music is from iPod, check MPMusicPlayerController's nowPlayingItem or

Changing the text on a UISwitch

我是研究僧i 提交于 2019-11-27 14:01:20
The UISwitch currently says ON and OFF. Can I change the text to YES and NO? Would it be hard? Or do I just rephrase the question I ask the user? As of iOS 6, you can set @property(nonatomic, retain) UIImage *offImage; @property(nonatomic, retain) UIImage *onImage; Docs say: 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. The size of this image must be less than or equal to 77 points wide and 27 points tall. If you specify larger images, the edges may be clipped. I've done