uiswitch

UISwitch is not working

て烟熏妆下的殇ゞ 提交于 2019-12-06 16:46:28
问题 First my .h file: @interface SettingsViewController : UIViewController <UINavigationControllerDelegate> { IBOutlet UISwitch *gravaSwitch; ... } @property (retain, nonatomic) UISwitch *gravaSwitch; ... @end My viewDidload in .m file (it works): ... // SET SWITCH BUTTON STATE keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"TrafficApp" accessGroup:nil]; if ( [[keychain objectForKey:(id)kSecAttrAccount] isEqualToString:@"" ] ) [self.gravaSwitch setOn:FALSE]; else [self.gravaSwitch

xHow to save UISwitch state whenever the application is quit (Swift)

大憨熊 提交于 2019-12-06 11:26:43
How can I save the state of multiple switches so when the application is quit and reopened, all of the switches are not at the same state they where before I quit it. Here is my very simple code for a quick homework manager I did. // // ViewController.swift // HomeworkManager // // Created by Nate Parker on 9/2/14. // Copyright (c) 2014 Nathan Parker. All rights reserved. // import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() {

UISwitch in TableView in Switch

笑着哭i 提交于 2019-12-06 04:08:15
问题 Hello fellow programmers! I have a challenge I need help with. I have built a table using a Custom Style Cell. This cell simply has a Label and UISwitch . The label displays a name and the switch displays whether they are an Admin or not. This works perfectly. My challenge is how and where do I put code to react when the switch is changed. So if I click the switch to change it from off to on where can I get it to print the persons name? If I can get the name to print I can do the php/sql code

How to change UISwitch default color for OFF state?

余生颓废 提交于 2019-12-06 03:58:17
问题 I want to change the color of onTintColor in the UISwitch for the off State. The switch is in tableview and switch is made programmatically. [settingsSwitch setBackgroundColor:[UIColor whiteColor]]; [settingsSwitch setTintColor:[UIColor whiteColor]]; [settingsSwitch setThumbTintColor:[UIColor redColor]]; [settingsSwitch setOnTintColor:[UIColor colorWithRed:138/256.0 green:9/256.0 blue:18/256.0 alpha:1]]; This is the result i get when i set the background color white. And without background i

How to get the value of a UISwitch?

不问归期 提交于 2019-12-05 09:32:41
问题 I am a newbie iOS programmer and I have a problem. I currently work on iOS Core Data and my problem is that I want to insert data into a boolean attribute to a database by taking the value of a UISwitch . The problem is that i don't know what it the method i have to call (e.g .text does the same thing but for UITextField). I have done a small google search but no results. Here is some code: [newContact setValue:howMany.text forKey:@"quantity"]; [newContact setValue:important.??? forKey:@

Showing and hiding UITableViewCell with UISwitch too fast crashes

岁酱吖の 提交于 2019-12-05 06:18:03
I've got a UITableView that presents some settings to the user. Some cells are hidden unless a UISwitch is in the 'On' position. I've got the following code: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return switchPush.on ? 6 : 1; } // Hooked to the 'Value Changed' action of the switchPush - (IBAction)togglePush:(id)sender { NSMutableArray *indexPaths = [NSMutableArray arrayWithCapacity:0]; for(int i = 1; i <= 5; i++) { [indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]]; } [tableView beginUpdates]; if(switchPush.on) { [tableView

Swift, Xcode - Increasing the size of a UISwitch

有些话、适合烂在心里 提交于 2019-12-05 00:55:38
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. kabiroberai According to this answer by the user mxg , just use the following code: mySwitch.transform = CGAffineTransformMakeScale(0.75, 0.75) Of course, you have to change mySwitch to whatever the name of your variable/IBOutlet is. Swift 3 / 4: switch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75) Xcode 9.2 & Swift 4 switch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75) Making a

How to call an action when UISwitch changes state?

…衆ロ難τιáo~ 提交于 2019-12-04 23:36:59
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. mac [yourSwitchObject addTarget:self action:@selector(setState:) forControlEvents:UIControlEventValueChanged]; This will call the below method when your switch state changes - (void)setState:(id)sender { BOOL state = [sender isOn]; NSString *rez = state == YES ? @"YES" : @"NO"; NSLog(rez); } Masih Obviously we can do the same with Swift, here is the code (compiled and worked with the latest version of the

UISwitch: Swift 3: Programmatically

…衆ロ難τιáo~ 提交于 2019-12-04 23:03:36
How can I programmatically add a uiswitch and call an action when on and one when off? Ive been searching for hours now. Can I please have some help? I know how to add the switch but it stays on the screen no matter what scene I'm on. So far, I've been able to add the button and make it switch from on to off, but for some reason the switch just says on the screen in every scene. I was lost after that so I followed this; from How to programmatically put a UISwitch in a SpriteKit/Skcene Yes it is possible. Just use this code in your SKScene class: override func didMoveToView(view: SKView) { /*

UISwitch is not working

时光毁灭记忆、已成空白 提交于 2019-12-04 21:46:00
First my .h file: @interface SettingsViewController : UIViewController <UINavigationControllerDelegate> { IBOutlet UISwitch *gravaSwitch; ... } @property (retain, nonatomic) UISwitch *gravaSwitch; ... @end My viewDidload in .m file (it works): ... // SET SWITCH BUTTON STATE keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"TrafficApp" accessGroup:nil]; if ( [[keychain objectForKey:(id)kSecAttrAccount] isEqualToString:@"" ] ) [self.gravaSwitch setOn:FALSE]; else [self.gravaSwitch setOn:TRUE]; ... But my switchChanged doesn't work and I don't know why. On IB everything is right