uiswitch

UITableViewCell and UISwitches - iPhone SDK

痞子三分冷 提交于 2019-12-25 04:43:28
问题 I am trying to save the states of an UISwitch for each cell in my UITableView. Is there a way to do this? I was thinking of using the NSUserDefault but I'm not too sure about saving the values with a given name and then retrieving that state when the cells are created. Any suggestions would be nice! Thanks, Kevin 回答1: you can try with following sample code; NSMutableDictionary *dictionay = [[NSMutableDictionary alloc] init]; [dictionay setObject:@"1" forKey:@"firstcell"]; [dictionay setObject

Communicating between view Controllers

≯℡__Kan透↙ 提交于 2019-12-24 11:08:51
问题 one of my view controllers has several UISwitches, and I want another view Controller to be able to access the values of the UISwitches for If/and statements. How do I do this in Objective-c? 回答1: You probably don't want to do that. If you want a second ViewController to have different behavior based on switches thrown in the first, you should just bind the switches to User Defaults, which you can read anywhere in your app. http://icodeblog.com/2008/10/03/iphone-programming-tutorial

Xamarin forms: Current listview switch state changing when the listview gets refresh?

亡梦爱人 提交于 2019-12-23 03:06:14
问题 I have a listview, which shows 20 users initially. Whenever the listview bottom reaches a new REST API call will start and it shows more users(20,40,60 etc). When loading more users the list gets refreshed. Listview items have a switch option and if I press the switch option the userid of that user is added to a list. If I again press the same switch that userid is removed from the list. My problem is the selected user's switches are going to off state when loading more users. But the userids

How to call an action when UISwitch changes state?

北城以北 提交于 2019-12-22 01:46:22
问题 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. 回答1: [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); } 回答2: Obviously

How to set UISwitch border color?

≯℡__Kan透↙ 提交于 2019-12-21 07:54:54
问题 My app has done: [[UIView appearance] setTintColor:[UIColor whiteColor]]; And here is what I have when on : and off : I need to make UISwitch border visible like in Settings.app: 回答1: Your [[UIView appearance] setTintColor:[UIColor whiteColor]]; is interfering with the tint color of your switch. The command to set the tint color is self.mySwitch.tintColor = [UIColor grayColor]; which sets the color used to tint the outline of the switch when it is turned off. 回答2: Will you please try adding

iOS - Moving a UITextField to a Different Position when a UIView Moves

故事扮演 提交于 2019-12-21 05:39:06
问题 I have a main UIView which moves up by means of a switch. I have this working and there is no problem there. Now the UIView when down, takes up about half of the Screen and when it is pushed up it shows the bottom 40px. In the UIView when it is down it has a UITextField and it sits somewhere in the middle. When the UIView is pushed up I want that UITextField to move to sit within those 40px, so that it always accessible. This is the code I got for the UIView to move: -(IBAction)mainview:(id

UISwitch setOn(:, animated:) does not work as document

六眼飞鱼酱① 提交于 2019-12-20 20:02:43
问题 As Apple's document write, UISwitch 's function setOn(on: Bool, animated: Bool) does not send action. It works fine before iOS 10, but it will send action after I call it in iOS 10. I call it in "ValueChanged" event to force switch back, so I got this event action twice. is it a bug in iOS 10? 回答1: DispatchQueue.main.async { sender.setOn(flag, animated: animated) } it works for me in Xcode 8. but call UISwitch.setOn(_:animated:) directly on main thread doesn't work. Update thanks to

UIswitch in a table cell reused

北战南征 提交于 2019-12-20 07:04:53
问题 I have a problem with uiswitch in my UITableViewCell that whenever i change a switch value in a specific cell that belongs to a specific section. All other sections cells that have same inexPath.row change . Please help ? Here is my code of cellForRowAtIndexPath method: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier

unable to save on/off state of a UITableViewCell?

懵懂的女人 提交于 2019-12-19 12:23:06
问题 there are two attributes 'time' and 'isOn' (string, bool) in the entity named 'Item' in viewcontroller class I am able to give default condition to 'isOn' attribute (in savePressed function) which makes switchbtn.isOn = true and saves it in the data model for that particular 'time' viewcontroller class :- class ViewController: UIViewController { let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext @IBOutlet weak var timePickerView: UIDatePicker!

unable to save on/off state of a UITableViewCell?

若如初见. 提交于 2019-12-19 12:21:12
问题 there are two attributes 'time' and 'isOn' (string, bool) in the entity named 'Item' in viewcontroller class I am able to give default condition to 'isOn' attribute (in savePressed function) which makes switchbtn.isOn = true and saves it in the data model for that particular 'time' viewcontroller class :- class ViewController: UIViewController { let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext @IBOutlet weak var timePickerView: UIDatePicker!