![](/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.