小编use*_*330的帖子

UIImage imageWithContentsOfFile正确的pathForResource

我有资源:

Test.png
test1.jpg
tesT2.jpg
tEst3.jpg
Run Code Online (Sandbox Code Playgroud)

我需要显示这个图像UIImageView.所以我写道:

imgView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[myObject.filename stringByDeletingPathExtension] ofType:[myObject.filename pathExtension]]];
Run Code Online (Sandbox Code Playgroud)

myObject是我模型中的实体.我filename从xml 获得,但在xml中它的格式如下:

filename="test.png"
filename="test1.jpg"
filename="test3.jpg"
filename="test3.jpg"
Run Code Online (Sandbox Code Playgroud)

所以我的Image是(null)因为在pathForResource中我搜索@"test" ofType "png",但需要@"Test" ofType"png".

如何在不重命名的情况下获得正确的资源?

objective-c uiimageview uiimage ios

3
推荐指数
1
解决办法
629
查看次数

Cocoapods更新错误

我从github拉信息并运行pod update并得到此错误:

Setting up CocoaPods master repo
Already up-to-date.
[!] The `master` repo requires CocoaPods 0.29.0 - 
Update CocoaPods, or checkout the appropriate tag in the repo.

    /Library/Ruby/Gems/2.0.0/gems/claide-0.4.0/lib/claide/command.rb:217:in `rescue in run': undefined method `verbose?' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/2.0.0/gems/claide-0.4.0/lib/claide/command.rb:210:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/lib/cocoapods/command.rb:52:in `run'
        from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/bin/pod:24:in `<top (required)>'
        from /usr/bin/pod:23:in `load'
        from /usr/bin/pod:23:in `<main>'
Run Code Online (Sandbox Code Playgroud)

编辑

我尝试sudo gem update将此更新cocoapods改为0.29.然后我运行pod更新并获取:

Unable to find a specification for `cdebug`.
Run Code Online (Sandbox Code Playgroud)

git objective-c cocoapods

0
推荐指数
1
解决办法
748
查看次数

标签 统计

objective-c ×2

cocoapods ×1

git ×1

ios ×1

uiimage ×1

uiimageview ×1