【发布时间】:2015-05-11 21:36:43
【问题描述】:
我想通过按下第二个界面控制器中的蓝色按钮来更新第一个界面控制器中的按钮标题(灰色按钮)。
我可以使用计数器来更新标签,但是我该如何将结果发送回第一个接口控制器
是否应该在第二个接口控制器中执行,然后通过push segue发回结果
我将如何使用
pushControllerWithName("secondController",context: ... )
我应该这样做吗:
var counter = 1
@IBAction func addOne() {
greyButtonLabel.setTitle("\(counter++)")
pushControllerWithName("secondController", context : add)
}
// The second interface controller
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
if let addone = context as? counter {
greyButtonLabel.setTitle("\(counter++)")
}
}
【问题讨论】:
-
@BootMaker 另一个问题的代码在objectiveC中