That's because you're sleeping (and blocking) the thread that the alert should be presented from (the main/UI thread). I recommend you use dispatch_after
to sleep asynchronously, and then call back to the main thread after the 5 seconds has passed to dismiss the alert. Something like this:
UIAlertView *delayAlert = [[UIAlertView alloc]
initWithTitle:@"Delay"
message:@"This message follows with a 5 second delay."
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil, nil];
[delayAlert show];
double delayInSeconds = 5.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[delayAlert dismissWithClickedButtonIndex:0 animated:YES];
});