The following code works perfectly from iOS 5 to 6.1. I even have applications in store with that code:
-(void)showActivityIndicator
{
if(!mLoadingView)
now addSubview
is not available in UIAlertView
in iOS7
The UIAlertView
class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified
As an alternative you can use SVProgressHUD.
I had to fix this problem very quickly, hence I have built an iOS7 UIAlertView-style UIView with its animations, which can be extended with any custom content.
There might be others who can use my solution, so I made the whole code available on Github.
Also, if you want to keep using the UIAlertView under previous OS versions, you have to fork the code. It might be as bad as it sounds, I'm using the following:
float sysVer = [[[UIDevice currentDevice] systemVersion] floatValue];
if (sysVer < 7) {
// your old solution
} else {
.. // iOS7 dialog code
}
(Please be aware that this is by no means a real solution - if Apple doesn't want us to use the dialogs for all sorts of things, then we probably shouldn't.)
From iOS 7 onwards, you can do:
[alertView setValue:customContentView forKey:@"accessoryView"];
to get custom content in a standard alert view.