[ad_1]
I’m completely new at Swift, and am constructing a referral type. Some pages of the shape have tickboxes the place the person can choose what kind of assist they want. I’ve created these tickboxes as cells for a UITableView. They’ve their very own view and nib, and are made up of a button and a picture for suggestions. Here is the code:
class TickboxCell: UITableViewCell {
@IBOutlet weak var supportBox: UIView!
@IBOutlet weak var supportBtn: UIButton!
@IBOutlet weak var checkmark: UIImageView!
override func awakeFromNib() {
tremendous.awakeFromNib()
// Initialization code
}
override func setSelected(_ chosen: Bool, animated: Bool) {
tremendous.setSelected(chosen, animated: animated)
// Configure the view for the chosen state
}
@IBAction func buttonPressed(_ sender: UIButton) {
if supportBtn.isSelected == false {
supportBtn.isSelected = true
checkmark.picture = UIImage(named: Okay.Photos.checked)
} else {
supportBtn.isSelected = false
checkmark.picture = UIImage(named: Okay.Photos.notChecked)
}
}
}
Within the ViewController for the web page, I am attempting to create a perform whereby, when the person presses the Subsequent button to go to the subsequent web page of the shape, all of the labels of the buttons which have been chosen are saved after which handed onto the ultimate web page of the referral type, able to be emailed.
That is the place I am at with the perform:
func getTicks() {
var ticks: [String:String?] = [:]
for cell in self.tableView.visibleCells {
if cell.supportBtn.isSelected == true {
if let title = cell.supportBtn.titleLabel?.textual content {
ticks.updateValue("Sure", forKey: title)
}
}
}
}
In fact, this does not work as a result of the seen cells do not have what I am on the lookout for. They solely have properties like baseClass and body.
In my perform for the tableView, there’s the road
let cell = tableView.dequeueReusableCell(withIdentifier: Okay.cellIdentifier, for: indexPath) as! TickboxCell
I do know that is the place it makes the tableView cells into the Tickbox cells – I set the titleLabels for the cell buttons after that. So can I work this into the above perform someway? Or is there one other solution to faucet into the chosen standing and titles of my buttons?
That is my first ever query on right here, apologies if there’s something mistaken with it!
[ad_2]
