gpt4 book ai didi

iphone - 在ios中的特定时间调用警报

转载 作者:可可西里 更新时间:2023-11-01 05:42:10 28 4
gpt4 key购买 nike

我正在开发应用程序,它会根据用户输入在 iOS 上设置一段时间的闹钟。

含义:如果用户选择表格的第 1 行,那么它会查看字典(可能说 20 分钟),然后它应该在 ios 中设置一个闹钟(当前时间 + 20 分钟)。

谁能告诉我解决这个问题的最佳方法。

最佳答案

你可以使用 UILocalNotification:

UILocalNotification *local = [[UILocalNotification alloc] init];

// create date/time information
local.fireDate = [NSDate dateWithTimeIntervalSinceNow:20*60]; //time in seconds
local.timeZone = [NSTimeZone defaultTimeZone];

// set notification details
local.alertBody = @"Alarm!";
local.alertAction = @"Okay!";


local.soundName = [NSString stringWithFormat:@"Default.caf"];

// Gather any custom data you need to save with the notification
NSDictionary *customInfo =
[NSDictionary dictionaryWithObject:@"ABCD1234" forKey:@"yourKey"];
local.userInfo = customInfo;

// Schedule it!
[[UIApplication sharedApplication] scheduleLocalNotification:local];

[local release];

关于iphone - 在ios中的特定时间调用警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11203083/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com