ios - Objective C 中 UILocalNotification 的图标

标签 ios objective-c xcode uilocalnotification

如何在 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/

相关文章:

ios - NS_OPTIONS 位掩码自动生成

ios - 函数的混合 - 以及仅在运行时已知的函数

ios - 在 Ios 中合并两个视频

objective-c - 在屏幕保护程序中嵌入自定义字体

swift - 尝试进行涉及 webview 的 UI 测试时 Xcode 崩溃

android - 用xcode开发android应用

xcode - Teamviewer-从Windows向Mac发送控制键

objective-c - 使用不兼容类型 'double' 的表达式初始化 'id'

objective-c - Xcode - 如何通过命令行更改文件的目标成员身份?

iphone - 获取 UITableview 中自定义单元格的行索引