我对 Xcode 比较陌生,我正在构建一个非常简单的闹钟,下面是应用程序的一个小片段。我的问题是:如何在触发警报时显示自定义 View (即图片或动画),并在其上放置一个“关闭”按钮?提前谢谢你
尼古拉
- (void) scheduleLocalNotificationWithDateNSDate *)fireDate NSString *)message
{
UILocalNotification *notificaiton = [[UILocalNotification alloc] init];
if (notificaiton == nil)
return;
notificaiton.fireDate = fireDate;
notificaiton.alertBody = message;
notificaiton.timeZone = [NSTimeZone defaultTimeZone];
notificaiton.alertAction = @"View";
notificaiton.soundName = @"alarm-clock-1.mp3";
notificaiton.applicationIconBadgeNumber = 1;
notificaiton.repeatInterval = kCFCalendarUnitWeekday;
NSLog(@"repeat interval is %@",notificaiton.description);
[[UIApplication sharedApplication] scheduleLocalNotification:notificaiton];
Best Answer-推荐答案 strong>
使用这个方法
Handle the notificaton when the app is running
- (void)applicationUIApplication *)app didReceiveLocalNotificationUILocalNotification *)notif
{
// show your custom alert view
}
Handle launching from a notification
- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions {
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif)
{
// show your custom alert view
}
return YES;
}
关于ios - 触发本地通知时的自定义 View ,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/17700606/
|