himanth himanth - 1 year ago 69
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
Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download