我想将图片资源包含在cocoapod库中,但我无法访问它们。我读过这些资源的帮助:pod中的访问资源
然而,没有点我在访问资源的方向。我已经试过如下:
[UIImage imageWithData:[NSData dataWithContentsOfURL:[(NSBundle *)[NSBundle bundleWithIdentifier:@"Assets"] URLForResource:@"[email protected]" withExtension:@"png"]]]
[UIImage imageWithData:[NSData dataWithContentsOfURL:[(NSBundle *)[NSBundle bundleWithIdentifier:@"Assets"] URLForResource:@"my-image" withExtension:@"png"]]]
[UIImage imageWithData:[NSData dataWithContentsOfURL:[(NSBundle *)[NSBundle bundleWithIdentifier:@"Assets.bundle"] URLForResource:@"my-image" withExtension:@"png"]]]
[UIImage imageWithData:[NSData dataWithContentsOfURL:[(NSBundle *)[NSBundle mainBundle] URLForResource:@"my-image" withExtension:@"png"]]]
[[UIImage imageWithData:[NSData dataWithContentsOfURL:[(NSBundle *)[NSBundle mainBundle] URLForResource:@"[email protected]" withExtension:@"png"]]]
[UIImage imageNamed:@"my-asset"]
[UIImage imageNamed:@"[email protected]"]
但他们没有工作。
我设置我的podspec这些替代品和上述既不工作:
s.resources = ['Pod/Assets/*.{png, jpg}', 'Pod/Assets/**/*.{png, jpg}']
s.resource_bundles = {
'Assets' => ['Pod/Assets/*.{png, jpg}', 'Pod/Assets/**/*.{png, jpg}']
}
资源出现在“发展豆荚/我的应用程序/资源”一pod update
后,但我不能访问它们为了我的生活。没有任何捆绑,并且没有任何名为“资产”的东西。
任何帮助或指导,将不胜感激。
你两者都做's.resources'和's.resource_bundles'或单独审判呢?也许有一些冲突。 – 2014-09-14 07:42:20
@NiklasBerglund分别。 – RileyE 2014-09-14 21:21:42