![](/img/trans.png)
[英]Swift 3 - How can I store the current value of a UISwitch in a UITableViewCell, in a variable on the actual ViewController?
[英]ios7 how can I get UITableViewCell's UISwitch value?
我在UITableViewCell上使用UISwitch。 当我按下保存按钮时,我想获取UISwitch值。 我怎么才能得到它? 我的代码如下:
- (void)save:(id)sender
{
UITableViewCell *commentCell = [self.tableView dequeueReusableCellWithIdentifier:@"CustomInfoCell" forIndexPath: [NSIndexPath indexPathForRow:0 inSection:0]];
UISwitch* commentSwitch = (UISwitch*)[commentCell viewWithTag:2];
NSLog(@"%@", [NSNumber numberWithBool:commentSwitch.on]);
}
- (void)save:(id)sender
{
UITableViewCell *commentCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
UISwitch* commentSwitch = (UISwitch*)[commentCell viewWithTag:2];
NSLog(@"%@", [NSNumber numberWithBool:commentSwitch.on]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.