繁体   English   中英

ios7如何获取UITableViewCell的UISwitch值?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM