imagenamed

Loading NSImage with imageNamed from xcassets crash in older osx versions

≯℡__Kan透↙ 提交于 2020-01-14 07:34:07
问题 So, I have an xcassets that is shared amongst quite a few apps. I'm developing with Xcode8 in a Mac Mini with MacOs Sierra installed in it. If I compile and run in the development machine, there's no issue at all. However, when I try to run it in a device with OSX Mavericks I get a crash. Here's the trace in the report Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x00007fff887dc866 __pthread_kill + 10 1 libsystem_pthread.dylib 0x00007fff87a3935c pthread

How to get [UIImage imageWithContentsOfFile:] and High Res Images working

佐手、 提交于 2019-12-29 18:01:09
问题 As many people are complaining it seems that in the Apple SDK for the Retina Display there's a bug and imageWithContentsOfFile actually does not automatically load the 2x images. I've stumbled into a nice post how to make a function which detects UIScreen scale factor and properly loads low or high res images ( http://atastypixel.com/blog/uiimage-resolution-independence-and-the-iphone-4s-retina-display/ ), but the solution loads a 2x image and still has the scale factor of the image set to 1

Use external image in UIImage imageNamed

痴心易碎 提交于 2019-12-13 13:09:31
问题 I am downloading two images from the web Apple.png and Apple@2x.png. I want to use [UIImage imageNamed:@"Apple.png"] so it can use the build in features to detect whether it should display either Apple.png or Apple@2x.png. Now where do I store these images? I read the following in the documentation: The name of the file. If this is the first time the image is being loaded, the method looks for an image with the specified name in the application’s main bundle. Ah so the Application's Main

ios开发UIImage imageNamed方法的误用

ぃ、小莉子 提交于 2019-12-11 11:23:48
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一、加载图片问题 UIImage image = [UIImage imageNamed:imageFileName]; 这种图片加载方式带有图片缓存的功能,使用这种方式加载图片后,图片会自动加入系统缓存中,并不会立即释放到内存。一些资源使程序中经常使用的图片资源, 使用这种方式会加快程序的运行减少IO操作,但对于项目中只用到一次的图片,如果采用这种方案加载,会增导致程序的内存使用增加。 以下为官方对此方法的解释说明: imageNamed: Returns the image object associated with the specified filename. + (UIImage *)imageNamed:( NSString *) name Parameters name The name of the file. If this is the first time the image is being loaded, the method looks for an image with the specified name in the application’s main bundle. Return Value The image object for the specified

imageNamed is evil - How to use the function

江枫思渺然 提交于 2019-12-11 04:47:17
问题 - (UIImage*)thumbnailImage:(NSString*)fileName { UIImage *thumbnail = [thumbnailCache objectForKey:fileName]; if (nil == thumbnail) { NSString *thumbnailFile = [NSString stringWithFormat:@"%@/thumbnails/%@.jpg", [[NSBundle mainBundle] resourcePath], fileName]; thumbnail = [UIImage imageWithContentsOfFile:thumbnailFile]; [thumbnailCache setObject:thumbnail forKey:fileName]; } return thumbnail; } I got this code from http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/ . Can someone

UIImage initWithContentsOfFile doesn't work

女生的网名这么多〃 提交于 2019-12-03 17:39:25
问题 I have question: I want to avoid [UIImage imageNamed:]. So i did: UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:@"myimage.png"]; controller.productImg.image = prodImg; [prodImg release]; But now the image is not shown anymore. Does anyone know how to get that to work? 回答1: The above code is not working because correct way to do it is- NSString *thePath = [[NSBundle mainBundle] pathForResource:@"default" ofType:@"jpeg"]; UIImage *prodImg = [UIImage imageWithContentsOfFile:thePath]

UIImage initWithContentsOfFile doesn't work

心已入冬 提交于 2019-12-03 05:51:22
I have question: I want to avoid [UIImage imageNamed:]. So i did: UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:@"myimage.png"]; controller.productImg.image = prodImg; [prodImg release]; But now the image is not shown anymore. Does anyone know how to get that to work? Devarshi The above code is not working because correct way to do it is- NSString *thePath = [[NSBundle mainBundle] pathForResource:@"default" ofType:@"jpeg"]; UIImage *prodImg = [UIImage imageWithContentsOfFile:thePath]; controller.productImg.image = prodImg; [prodImg release]; ;) 来源: https://stackoverflow.com

How to get [UIImage imageWithContentsOfFile:] and High Res Images working

99封情书 提交于 2019-11-29 23:18:56
As many people are complaining it seems that in the Apple SDK for the Retina Display there's a bug and imageWithContentsOfFile actually does not automatically load the 2x images. I've stumbled into a nice post how to make a function which detects UIScreen scale factor and properly loads low or high res images ( http://atastypixel.com/blog/uiimage-resolution-independence-and-the-iphone-4s-retina-display/ ), but the solution loads a 2x image and still has the scale factor of the image set to 1.0 and this results to a 2x images scaled 2 times (so, 4 times bigger than what it has to look like)

JPG image doesn't load with UIImage imageNamed

倾然丶 夕夏残阳落幕 提交于 2019-11-29 03:05:43
I read on the reference that from iOS version 4.+ with the method imageNamed of UIImage object, the file extension is not required. From UIImage class reference: Special Considerations. On iOS 4 and later, the name of the file is not required to specify the filename extension. Prior to iOS 4, you must specify the filename extension. But it seems that this only work with PNG files. If my code is: [UIImage imageNamed:@"test"]; The image loads only if the file is test.png The image doesn't load if it's test.jpg . For me it is a big problem because I need to maintain a dynamic image loading (I do

use xcassets without imageNamed to prevent memory problems?

て烟熏妆下的殇ゞ 提交于 2019-11-28 06:52:46
according to the apple documentation it is recommended to use xcassets for iOS7 applications and reference those images over imageNamed. But as far as I'm aware, there were always problems with imageNamed and memory. So I made a short test application - referencing images out of the xcassets catalogue with imageNamed and started the profiler ... the result was as expected. Once allocated memory wasn't released again, even after I removed the ImageView from superview and set it to nil. I'm currently working on an iPad application with many large images and this strange imageView behavior leads