Creating CPTImages from images in xcassets file - core-plot

So according to this, you have to use imageNamed for loading images now in iOS.
Unfortunately, CPTImage's constructors requires paths for loading images
So something like this:
[CPTImage imageForPNGFile:[[NSBundle mainBundle] pathForResource:#"plotsymbol" ofType:#"png"]]
These -pathForResource calls now fail because of asset catalogs.
So.. has anyone been able to do this? Did I miss something?

The CPTImage class will include an imageNamed method in a future release. It is available now on the release 2.0 branch. People are using the 2.0 code now but it is unfinished and subject to change in many areas before the final release.

Related

UIImage Caching

Its is well documented that UIImage imageNamed caches the images. And the trend with the newer version of iOS is to use Asset Files to simplify all the #2x and #3x images for all devices.
But to avoid caching the images and to make best use of memory with images, so far I would use methods like imageWithData. But these methods don't work with Asset files that has been my understanding so far. Cause I could not find methods like pathForResource on the bundle working properly for Asset images. Is this a drawback on iOS or is there a nice workaround or is it just plain n00b ness on my behalf?
On one of my projects I have noticed a large memory consumption only because some image used on some startup screen or so still being cached courtesy imageNamed:
How can one work around this i.e continue using the simplicity and ease of Asset set Images and yet avoid caching using imageNamed:
Thanks
Although UIImage's imageNamed caches the images, and some of the old forums continue to dole out that information. In earlier OS version, imageNamed had a memoryLeak, which has long been fixed.
When app receives memory warning, cache is cleared. So you can continue to use it.

IDMPhotoBrowser doesn't load image from AWSS3 bucket

I am working on integrating IDMPhotoBrowser into my app that uses an AWSS3 bucket. If I enter the link into my browser, it properly downloads the image. If I pass the link through an AWSS3TransferManager it also works. It even works when I use SDWebImage and specify the url.
For some reason however, when I put the url into IDMPhotoBrowser, it will not load. I have tested it with other images not located in the bucket and they will load fine. I also have checked that the bucket is set to public, as are its objects.
I am about to attempt to use the MWPhotoBrowser since it uses SDWebImage. If anyone has any other suggestions please let me know!
I was not able to determine why, but I found that AFNetworking as currently set up through IDMPhotoBrowser does not work with AWSS3.
There are two solutions. One was to use MWPhotoBrowser, which I implemented. The second was that there is a branch of IDMPhotoBrowser that another user has edited to use SDWebImage instead of AFNetworking. That repository can be found here: https://github.com/mythodeia/IDMPhotoBrowser
Hope this helps anyone else stuck on this problem even though I couldn't really solve it...only work around it.

Adding image sets to images.xcassets catalog programmatically in iOS?

I've searched high and low on stackoverflow and google for an answer to this question. Perhaps it's not possible, or I may need to devise a different method to do this.
In our iOS app we have a whole bunch of image sets in images.xcassets. But we're moving to a more dynamic environment where we'll be downloading image sets instead.
I'd like to try and stick with the convention of having everything in the images.xcassets folder. Except as said, I want to dynamically create the image sets based on the data we retrieve from our server. Is this possible?
So there is a way to do this, but it's iOS 8.0 and above. Unfortunately, we're supporting 7 and above so I can't use it.
But for anyone else who's interested, you can use the UIImageAsset class to do what you need to do when you want to create a container for your images to encapsulate different resolutions, as the images.xcassets container currently does.
UIImageAsset docs
This answer gives a good overview of the XCAssets folder at runtime: Can I access an xcassets directory on the filesystem? - it looks like it's the wrong way of going about things.
I believe it is recommended that you use the temp or document folders, depending on the how long you wish to keep these images (https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html).

forge.topbar.setTitleImage(URL,success,error); dynamic image .. fileCache?

I have been told this is possible to do but cannot get this to work.
Basically I am trying to cache and image using forge.file.cacheURL()
Now I can get the file just fine and display it in the page by creating a new Image object but what I want to do is use this cached image to change the image in the topbar.
When ever I try to do it I get an error saying "file not found" and after reading the docs a little more it seems that trigger may have "src/" coded into the class because if I put just "image/logo.png" the logo.png will show up in the header because its part of the app package.
I guess the question is.. Is my assumption correct?
Thanks!
The native UI elements (topbar/tabbar) load images directly from your apps package, not through a URL in the same ways images are shown in the webview.
What this means is that currently you can only use images included in your app in the topbar/tabbar modules.
in case anyone is interested in this, the ability was added a while ago to the API so you can now use a cached image or filesaveURL feature of forge to change the header image dynamically.

Add downloaded resources (images) to Bundle?

I am developing an application which is a kind of contact list. This list is updated each times the applications starts.
Each contact in the list has its own photo. A part of this list is common for every user of this application. For this part, I already have all the needed pics and I inlude them in the bundle/archive (which will be sent to Apple).
The pics of the new contacts (added during the lifetime of the app) are downloaded from a remote server (using ASIHTTPRequest). But I don't know how to handle these downloaded pics easily.
I am looking for a way to add these downloaded pics to the main bundle so I can call them using :
+ (UIImage *)imageNamed:(NSString *)name
Do you have any idea of the good practices for this kind of things ?
If new resources can't be added to the main bundle, what are your recommendations ?
Thanks again for your help !
kheraud
You can only add files to your App's Documents directory. The main bundle can't be modified after your App has been released. Read the documentation on how to write to the directory.
Edit_: This should help you to get started http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/StandardBehaviors/StandardBehaviors.html%23//apple_ref/doc/uid/TP40007072-CH4-SW6
I'm doing a similar thing for an app, and in the past I've used a couple of different Categories for UIImage.
For the current version I'm looking at https://github.com/rs/SDWebImage but I had really good luck using this one in a previous version https://github.com/jaanus/UIImageViewCached. For my purpose, I was downloading images from a URL and then caching them for use in a TableView.
HTH

Resources