可以说我有2 ViewControllers
,在我的MainViewController我有一个按钮,执行segue到SecondViewController。当点击按钮时,我将一些初始数据保存到coreData,因此需要一些时间。如何显示活动指标,而在视图控制器之间传递
这是我想要做的事情; 在ViewControllers之间传递时,我想显示ActivityIndicator
,但它在SecondViewController打开后启动。你可以帮帮我吗?我是Swift新手。
这是我在MainVC使用的代码:你需要调用它的按钮行动,并呼吁performSegue(withIdentifier:sender:)
方法之后
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "SecondViewController") {
SwiftSpinner.show("Loading") // Act. indicator found on github
willRunOnce() // Here Im saving data to CoreData
SwiftSpinner.hide()
}
}
您必须出示按钮点击微调后必须隐藏它'prepareForSegue' – Aditya