I want to add an activity indicator to the view when a user saves information for a post. However, the swift file that controls the saving the info is not a UIView controller. It refers to a different Viewcontroller, and its settings at the top of the page are as follows:
protocol CustomCellDelegate {
func dateWasSelected(selectedDateString: String)
func textfieldTextWasChanged(newText: String, parentCell: CustomCell)
func entranceFeeWasChanged(newText:String, parentCell: CustomCell)
}
This is how I have wanted to set up the activity indicator to run once the save button is tapped:
var activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
and then (in a closure):
activityIndicator = UIActivityIndicatorView(frame: CGRectMake(0,0,50,50))
activityIndicator.center = self.view.center //centers the indicator
activityIndicator.hidesWhenStopped = true
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
view.addSubview(activityIndicator)
activityIndicator.startAnimating()
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
But the code won't work... specifically the self.view.center and the view.addSubview gives errors. I presume this is because the swift file is not a view controller. Is there a way to get around this?