Is the progress bar added to the top level UIWindow?
My guess is that because UIAlertView creates its own UIWindow, your code in sendGratuityRequest
is adding the bar to that window, which will get removed shortly after the button press.
Two possible solutions:
Put your code in
alertView:didDismissWithButtonIndex:
instead ofalertView: clickedButtonAtIndex:
. (I'm not 100% sure this will fix it.)Use better logic to select the correct UIWindow. Proper code might look like this, but could be different depending on how your app uses UIWindows:
NSEnumerator *frontToBackWindows = [[[UIApplication sharedApplication]windows]reverseObjectEnumerator]; for (UIWindow *window in frontToBackWindows) if (window.windowLevel == UIWindowLevelNormal) { // Add the progress bar to this UIWindow break; }