【发布时间】:2019-09-07 12:26:34
【问题描述】:
我正在尝试制作自己的 cocoapods,我使用了图像。 当我按照教程进行操作时,出现错误。
.podspec
s.resource_bundles = {
'SSSlidingSelector' => ['SSSlidingSelector/Assets/*.xcassets']
}
类/SlidingSelector.m
- (UIImage *)getImageWithName:(NSString *)imageName {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [bundle URLForResource:@"SSSlidingSelector" withExtension:@"bundle"];
NSBundle *targetBundle = [NSBundle bundleWithURL:url];
UIImage *image = [UIImage imageNamed:imageName
inBundle:targetBundle
compatibleWithTraitCollection:nil];
return image;
}
错误
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: nil URL argument'
我的代码有什么问题? 谢谢
【问题讨论】:
-
我刚刚对此进行了测试,该功能按预期工作。您使用的是哪个版本的 Cocoapods?
-
1.7.5 @alxlives
标签: ios objective-c cocoapods nsbundle