【发布时间】:2016-10-04 15:04:37
【问题描述】:
我有一个 SegmentedControl。当用户单击它时,会出现一个确认对话框,询问他们是否希望更改该值。如果他们点击“取消”,我想取消对 SegmentedControl 值的更改。
这是我的一个代码段:
@IBAction func indexChanged(_ sender: UISegmentedControl) {
let refreshAlert = UIAlertController(title: "Update", message: "Sure you wanna change this?", preferredStyle: UIAlertControllerStyle.alert)
refreshAlert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action: UIAlertAction!) in
}))
refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action: UIAlertAction!) in
// Nothing
}))
present(refreshAlert, animated: true, completion: nil)
}
提前致谢。
【问题讨论】:
标签: ios swift xcode uisegmentedcontrol