-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwitchTableViewCell.swift
41 lines (32 loc) · 1.04 KB
/
SwitchTableViewCell.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// SwitchTableViewCell.swift
// Yelp
//
// Created by Nilesh Agrawal on 9/26/15.
// Copyright © 2015 Timothy Lee. All rights reserved.
//
import UIKit
@objc protocol SwitchTableViewDelegate{
func switchCell(switchCell:SwitchTableViewCell ,didChangeValue value:Bool)
}
class SwitchTableViewCell: UITableViewCell {
@IBOutlet weak var tableViewCellLabel: UILabel!
@IBOutlet weak var selectSwitch: UISwitch!
weak var delegate:SwitchTableViewDelegate?
override func awakeFromNib() {
super.awakeFromNib()
selectSwitch.setOn(false, animated: false)
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
@IBAction func selectSwitchSelected(sender: AnyObject) {
if selectSwitch.on {
delegate?.switchCell(self, didChangeValue: true)
}else{
delegate?.switchCell(self, didChangeValue: false)
}
}
}