How do I add a UIActivityIndicatorView spinner circle into a UIBarButton, so that when a user taps on one of those buttons on the navigation bar, they see a spinner while the loading takes place?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Navigation bar disappears when typing in UISearchC
- Can not export audiofiles via “open in:” from Voic
Place the following where ever is needed:
pseudocode, i'm not going to check this in Xcode, but something like this should work:
Actually activity indicator is not added as toolbar item. It's a subview of current view.
Remember to release it in
-(void)dealloc
.If you're trying to show the activity wheel in a navigation bar button (e.g. you might have a refresh button on your navbar) - you can create a new
UIBarButtonItem
with a custom view being theUIActivityIndicatorView
:Objective-C
Swift
This overwrites your
rightBarButtonItem
with the spinning wheel. When you're done, just recreate therightBarButtonItem
.UIActivityIndicatorView is a type of view. Set its frame to be within your button and use -addSubview to add it to the view hierarchy of the UIBarButton.
I'm oversimplifying, since you have to try to make it fit the space (possibly by scaling) and center it...
Use this Methods
}
}