![](/img/trans.png)
[英]pass data from custom cell(in table which is on ViewController) to the viewcontroller itself Swift3 iOS
[英]How to set/pass value from a custom cell to a viewcontroller in Swift
在我的程序中,在视图控制器下的UITableView的自定义UITableCell中有一个UISwitch。 我在视图控制器中创建一个变量,并尝试记录所有UISwitch.on的数量。
如何通过UISwitch Action在视图控制器中设置值?
我在UISwitch Action中编写了这些代码。 count是ViewController中的变量
var rootViewController = self.window!.rootViewController as ViewController
rootViewController.count++
println("count:\(rootViewController.count)")
它可以在我的示例程序中使用,但是当我在正式程序中编写时会出错。 它始终显示“线程1:EXC_BREAKPOINT(代码= EXC_I386_BPT,子代码= 0x0)”。
我还有另一种方式记录UISwitch.on的金额吗?
使用委托可以做到这些。
当开关打开时,视图控制器中存在的呼叫委托。
在委托方法中,递增计数变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.