gpt4 book ai didi

ios - Objective C 中 UILocalNotification 的图标

转载 作者:行者123 更新时间:2023-11-29 11:58:43 24 4
gpt4 key购买 nike

如何在 Objective-c 中将图标图像(应用程序图标图像除外)设置为 UILocalNotification。我尝试了一些代码通过设置 alertLaunchImage 属性来设置图像。但它不会更改图标。

如何解决这个问题?

最佳答案

它必须是应用程序包中存在的图像文件的文件名字符串。(注意:它是图像的名称不是 UIImage 对象)

下面的代码对我来说工作得很好:

UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertLaunchImage = @"icon.png";
// If you do not set the image, then it shows the app's default icon here

来自文档:

Composing the Alert alertBody Property alertAction Property alertTitle Property hasAction Property alertLaunchImage Property Identifies the image used as the launch image when the user taps (or slides) the action button (or slider).

Declaration OBJECTIVE-C @property(nonatomic, copy) NSString *alertLaunchImage Discussion The string is a filename of an image file in the app bundle. This image is a launching image specified for a given notification; when the user taps the action button (for example, “View”) or moves the action slider, the image is used in place of the default launching image. If the value of this property is nil (the default), the system either uses the previous snapshot, uses the image identified by the UILaunchImageFile key in the app’s Info.plist file, or falls back to Default.png.

The value of this key has the exact same semantics as UILaunchImageFile. For more about this key, see the Information Property List Key Reference.

Availability Available in iOS 4.0 and later.

( source )

关于ios - Objective C 中 UILocalNotification 的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37983141/

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