ios - Access UISwitch in Prototype Cell -
When I change the status of my UISwitch, I am trying to print / close.
For example
- (IBAction) toggle switch: (ID) sender {ChannelsTableViewCell * cell = (ChannelsTableViewCell *) [Sender Supervision]. Superview; NSIndexPath * indexPath = [self.tableView indexFaceReserveCell: cell]; If (cell.localSwitch.on) {NSLog (@ "on"); }} When I run it, it throws an error.
2014-04-24 11: 33: 41.462 HRAP [3258: 60b] - [UITableViewCellScrollView localTitle]: Unexpected selector sent for example 0x19354410 2014-04-24 11: 33: 41.467 HRAP I
If you hook up to IBAction in the switch, you will be able to check the value of the don switch. You do not need to get a UITableViewCell You can use the sender parameter from IBAction therefore: - (IBAction) toggle Switch: (ID) Sender {UISwitch * switch = (UISwitch *) Sender; If (switch.on) {NSLog (@ "on"); }} If you need to find the indexPath on which the UISwitch is shown, you can add the following: CGPETent pointInatable = [switch convert point: switch.bonds.organ View: statelessview]; NSIndexPath * indexPath = [self.tableView Index PathForRowAtPoint: pointInTable];
Comments
Post a Comment