简体   繁体   中英

Should I stop indicator animation right before dismissing view?

I know it doesn't really matter in terms of resources but In terms of good practice, I have an activity indicator that starts animating somewhere, and when the task is finished, I dismiss the view that contains that activity indicator. So, because the view is being deallocated it seems redundant to actually tell the activity indicator to stop animating.

So is this code redundant? :

  activityIndicator.stopAnimating() // should this be deleted?
  viewController.dismiss(animated: true)

When you call dismiss function, it dismisses the view controller that was presented modally by the view controller: which removes the VC from memory stack and deallocate all the memory of VC and it's elements. So you can remove the activityIndicator.stopAnimating() line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM