简体   繁体   中英

How to set the Timer in iphone

I just want to set the timer for the recorded voice. So, that it comes like an alarm after that time.(just like notifications). Is that possible.. Any help will be greatly appreciated...

Thanks in Advance

You might want to look at local notifications and NSTimer . Note that NSTimer doesn't work when the app is in the background.

Here is an example with NSTimer :

- (void)bar {
  [NSTimer scheduledTimerWithTimeInterval:200.0f
                                  target:self
                                selector:@selector(foo:)
                                userInfo:nil
                                 repeats:YES];
}

- (void)foo:(NSTimer *)timer {
  // Show alert or play recorded sound…
}

I'm afraid you can't play the recorded sound with local notifications, only when the app is in the foreground.

尝试阅读开发人员文档中的NSTimer类,或者您可以参考此链接

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM