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