Closed Ludotrico closed 3 years ago
You need to override func customDidSelect()
Create a row subclass and add UIActivityIndicator to cell.
`open class _RowPresenter
open var spinner: UIActivityIndicatorView = UIActivityIndicatorView(style: .medium)
private func addSpinnerToCell() { spinner.hidesWhenStopped = true cell.addSubview(spinner) //do layout stuff }
required public init(tag: String?) { super.init(tag: tag)
addSpinnerToCell()
}
open override func customDidSelect() { super.customDidSelect() if let presentationMode = presentationMode, !isDisabled { if let controller = presentationMode.makeController() { controller.row = self onPresentCallback?(cell.formViewController()!, controller)
spinner.startAnimating()
// do API call
// call line below when ready to present
presentationMode.present(controller, row: self, presentingController: cell.formViewController()!)
} else {
presentationMode.present(nil, row: self, presentingController: cell.formViewController()!)
}
}
}`
Closing due to lack of activity
My code currently looks like this:
This works fine but I would like to complete an API call when the user selects on the row. As of now, when the user taps on the row, it immediately pushes the view controller. I would like for the activity indicator to appear in the row, and only push the view controller once my API call is completed. How can I do this?