himanth himanth - 27 days ago 4
Objective-C Question

How to show time in UIAlertView?

In my app I'm implementing audio recorder. Everything working fine.

But when user taps on record button I have to show

with time in seconds.

So that user can easily understand like recording.

I don't have any idea about this.

How can I do this or suggest me any other idea please.

Pol Pol

UIAlertView is deprecated in iOS 8, now you can use UIAlertController with a preferredStyle of alert.

If the seconds are statics you can use

UIAlertController* alert = [UIAlertController alertControllerWithTitle:@“Your title string”
                                                               message:[NSString stringWithFormat:@“Seconds: %f”,yourSecondsVariable];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK",nil)
                                                       handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];

[self presentViewController:alert animated:YES completion:nil];

I think that you can use timeIntervalSinceDate: (of NSDate) to initialize your yourSecondsVariable.