给定包ID的包图标

时间:2011-03-28 21:37:59

标签: iphone objective-c cocoa-touch bundle

有没有办法(如果是这样,如何)获取给定应用包ID的图标。假设我有一个UIImage,我想要包含与Facebook应用相关联的图标(如果已安装在我的iOS设备上)。

2 个答案:

答案 0 :(得分:4)

您可以使用私有API。这可能对内部应用程序有用。

@interface UIImage (UIApplicationIconPrivate)
/*
 @param format
    0 - 29x29
    1 - 40x40
    2 - 62x62
    3 - 42x42
    4 - 37x48
    5 - 37x48
    6 - 82x82
    7 - 62x62
    8 - 20x20
    9 - 37x48
    10 - 37x48
    11 - 122x122
    12 - 58x58
 */
+ (UIImage *)_applicationIconImageForBundleIdentifier:(NSString *)bundleIdentifier format:(int)format;
@end

答案 1 :(得分:0)

在生产应用程序中访问来自用户应用程序的数据是不可能的,正如Apple提供的iOS应用程序编程指南中明确和彻底定义的那样:

For security reasons, iOS restricts each application (including its preferences and data) to a unique location in the file system. This restriction is part of the security feature known as the application’s sandbox. The sandbox is a set of fine-grained controls limiting an application’s access to files, preferences, network resources, hardware, and so on. Each application has access to the contents of its own sandbox but cannot access other applications’ sandbox.

Link

虽然理论上可以在实践中使用,但它肯定会被禁止访问iOS App Store,因为它会直接违反上述指南。