The better place to place the UIActivity indicator is on navigation bar, so the activity indicator don't appears in the middle of the screen bothering the user in is normal interaction with the application.
To accomplish this, here you are a little code snipe for placing an little UIActivityIndicator at top right corner of the screen instead of a UIBarButton.
// Create a 'right hand button' that is a activity Indicator
CGRect frame = CGRectMake(0.0, 0.0, 25.0, 25.0);
self.activityIndicator = [[UIActivityIndicatorView alloc]
initWithFrame:frame];
[self.activityIndicator sizeToFit];
self.activityIndicator.autoresizingMask =
(UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
UIBarButtonItem *loadingView = [[UIBarButtonItem alloc]
initWithCustomView:self.activityIndicator];
loadingView.target = self;
self.navigationItem.rightBarButtonItem = loadingView;
I've found that code snippet in Even Davey's Blog
Enjoy it!
Hey guys, i just wanted you to know that I really love your blog and your weekly updates!!!
ReplyDeleteKeep up with your good work!
Thanks for what you've done so far :)
Max
Thanks for your support, Max. We'll try to keep this blog alive and updated every week.
ReplyDeleteRegards!
Sergio