Search Results

Search found 779 results on 32 pages for 'uiimage'.

Page 4/32 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • iPhone - User Defaults and UIImages

    - by Staros
    Hello, I've been developing an iPhone app for the last few months. Recently I wanted to up performance and cache a few of the images that are used in the UI. The images are downloaded randomly from the web by the user so I can't add specific images to the project. I'm also already using NSUserDefaults to save other info within the app. So now I'm attempting to save a dictionary of UIImages to my NSUserDefaults object and get... -[UIImage encodeWithCoder:]: unrecognized selector sent to instance I then decided to subclass UIImage with a class named UISaveableImage and implement NSCoding. So now I'm at... @implementation UISaveableImage -(void)encodeWithCoder:(NSCoder *)encoder { [encoder encodeObject:super forKey:@"image"]; } -(id)initWithCoder:(NSCoder *)decoder { if (self=[super init]){ super = [decoder decodeObjectForKey:@"image"]; } return self; } @end which isn't any better than where I started. If I was able to convert an UIImage to NSData I would be good, but all I can find are function like UIImagePNGRepresentation which require me to know what type of image this was. Something that UIImage doesn't allow me to do. Thoughts? I feel like I might have wandered down the wrong path...

    Read the article

  • iOS - when to remove subviews from UITableViewCell

    - by Milad Ghattavi
    I have a UITableView which a UIImage is added as a subview to each cell of it. The images are PNG transparent. The problem is when I scroll through the UITableView, the images get overlapped and then I receive the memory warning and stuff. here's the current code for configuring a cell: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } int cellNumber = indexPath.row + 1; NSString *cellImage1 = [NSString stringWithFormat:@"c%i.png", cellNumber]; UIImage *theImage = [UIImage imageNamed:cellImage1]; UIImageView *cellImage = [[UIImageView alloc] initWithImage:theImage]; [cell.contentView addSubview:cellImage]; return cell; } I know the code for removing the UIImage subview would be like: [cell.imageView removeFromSuperview]; But I don't know where to put it. I've placed it between all the lines; even added an else, in the if statement. didn't seem to work!

    Read the article

  • UIImage Object surprisingly returning null but not NSData

    - by riyaz
    i have created a sqlite db. and i have insert a few datas in my db.. UIImage * imagee=[UIImage imageNamed:@"image.png"]; NSData *mydata=[NSData dataWithData:UIImagePNGRepresentation(imagee)]; const char *dbpath = [databasePath UTF8String]; NSString *insertSQL=[NSString stringWithFormat:@"insert into CONTACTS values(\"%@\",\"%@\")",@"Mathan",mydata]; NSLog(@"mydata %@",mydata); sqlite3_stmt *addStatement; const char *insert_stmt=[insertSQL UTF8String]; if (sqlite3_open(dbpath,&contactDB)==SQLITE_OK) { sqlite3_prepare_v2(contactDB,insert_stmt,-1,&addStatement,NULL); if (sqlite3_step(addStatement)==SQLITE_DONE) { sqlite3_bind_blob(addStatement,1, [mydata bytes], [mydata length], SQLITE_TRANSIENT); NSLog(@"Data saved"); } else{ NSLog(@"Some Error occured"); } sqlite3_close(contactDB); } else{ NSLog(@"Failure"); } have written some codes to retrive the data sqlite3_stmt *statement; if (sqlite3_open([databasePath UTF8String], &contactDB) == SQLITE_OK) { NSString *sql = [NSString stringWithFormat:@"SELECT * FROM contacts"]; if (sqlite3_prepare_v2( contactDB, [sql UTF8String], -1, &statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { char *field1 = (char *) sqlite3_column_text(statement, 0); NSString *field1Str = [[NSString alloc] initWithUTF8String: field1]; NSLog(@"UserName %@",field1Str); NSData *data = [[NSData alloc] initWithBytes:sqlite3_column_blob(statement, 1) length:sqlite3_column_bytes(statement, 1)]; UIImage *newImage = [[UIImage alloc]initWithData:data]; NSLog(@"Image OBJ %@",newImage); NSLog(@"Image Data %@",data); } sqlite3_close(contactDB); } } sqlite3_finalize(statement); the problem is in log, inserted NSData object and retrieved NSData Objects are different (printing in log gives different stream) moreover Image OBJ is printed null in log.. Have seen similar questions in stackoverflow. But nothing seems to help. Please give some suggestions to overcome this issue.

    Read the article

  • How to crop the UIImage?

    - by Rajendra Bhole
    Hi, I develop an application in which i process the image using its pixels but in that image processing it takes a lot of time. Therefore i want to crop UIImage (Only middle part of image i.e. removing/croping bordered part of image).I have the develop code are, - (NSInteger) processImage1: (UIImage*) image { CGFloat width = image.size.width; CGFloat height = image.size.height; struct pixel* pixels = (struct pixel*) calloc(1, image.size.width * image.size.height * sizeof(struct pixel)); if (pixels != nil) { // Create a new bitmap CGContextRef context = CGBitmapContextCreate( (void*) pixels, image.size.width, image.size.height, 8, image.size.width * 4, CGImageGetColorSpace(image.CGImage), kCGImageAlphaPremultipliedLast ); if (context != NULL) { // Draw the image in the bitmap CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, image.size.width, image.size.height), image.CGImage); NSUInteger numberOfPixels = image.size.width * image.size.height; NSMutableArray *numberOfPixelsArray = [[[NSMutableArray alloc] initWithCapacity:numberOfPixelsArray] autorelease]; } How i take(croping outside bordered) the middle part of UIImage?????????

    Read the article

  • iPhone UIImage initWithData fails

    - by DD
    Hello all, I'm trying to code up an async image downloader. I use NSURLConnection to get the data into an NSMutableData and use that data once it is complete to initialize a UIImage. I checked the bytes and it downloads the entire image correctly (right number of bytes at least), however; when I call [UIImage imageWithData:data] and then check the properties of the image, it is zero width and a garbage number for height, in fact, same number no matter what the image is. I tried with bunch of different images, png, jpg, different urls, it always downloads the image completely but UIImage can't initialize with that data. What could I be doing wrong here? Thanks.

    Read the article

  • iPhone SDK - CGBitmapContextCreate

    - by nax_
    Hi, I would like to create an image of my own. I already know its width (320*2 = 640) and height (427). So I have some raw data : unsigned char *rawImg = malloc(height * width * 4 *2 ); Then, I will fill it :) Then, I have to do something like that to get a bitmap and return a (UIImage *) : ctx = CGBitmapContextCreate(rawImg,width*2,height,8, ???, ???, kCGImageAlphaPremultipliedLast); UIImage * imgFinal = [UIImage imageWithCGImage:CGBitmapContextCreateImage(ctx)]; CGContextRelease(ctx); return imgFinal; But I don't know how to create my context ctx, as you can see with the "???", even tough I read the documentation... Please help ! Thanks :)

    Read the article

  • How do I create an image for a UITableViewCell dynamically

    - by Xetius
    I want to dynamically create an image for a UITableViewCell which is basically a square with a number in it. The square has to be a colour (specified dynamically) and contains a number as text inside it. I have looked at the CGContextRef documentation, but can't seem to work out how to get the image to fill with a specified certain colour. This is what I have been trying so far. -(UIImage*)createCellImageWithCount:(NSInteger)cellCount AndColour:(UIColor*)cellColour { CGFloat height = IMAGE_HEIGHT; CGFloat width = IMAGE_WIDTH; UIImage* inputImage; UIGraphicsBeginImageContext(CGSizeMake(width, height)); CGContextRef context = UIGraphicsGetCurrentContext(); UIGraphicsPushContext(context); // drawing code goes here // But I have no idea what. UIGraphicsPopContext(); UIImage* outputImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return outImage; }

    Read the article

  • (iphone) maintaining CGContextRef or CGLayerRef is a bad idea?

    - by Eugene
    Hi, I need to work with many images, and I can't hold them as UIImage in memory because they are too big. I also need to change colors of image and merge them on the fly. Creating UIImage from underlying NSData, change color, and combine them when you can't have many images on memory is fairly slow. (as far as I can get) I thought maybe I can store underlying CGLayerRef(for image that will be combined) and CGContextRef(the resulting combined image). I am new to drawing world, and not sure if CGLayerRef or CGContextRef is smaller in memory than UIImage. I recently heard that w*h image takes up w*h*4 bytes in memory. Does CGLayerRef or CGContextRef also take up that much memory? Thank you

    Read the article

  • UIImage for UIImageView is nil

    - by yeesterbunny
    I'm having problem displaying UIImage in UIImageView. I looked all over stackoverflow for similar questions, but none of the fixes helped me. The image is indeed in my bundle File Inspector - Target Membership is checked for the image IBOutlet is connected (I have tried both using IBOutlet and doing it programmatically) Both png nor jpg works Here's the code for using Interface Builder - //@property and @synthesize set for IBOutlet UIImageView *imageView - (void)viewDidLoad { [super viewDidLoad]; NSAssert(self.imageView, @"self.imageView is nil. Check your IBOutlet connection"); UIImage *image = [UIImage imageNamed:@"banner.jpg"]; NSAssert(image, @"image is nil"); self.imageView.image = image; } This code will terminate with NSAssert, printing in the console that 'image is nil'. I also tried selecting the Image directly from the attributes inspector: However it still doesn't show the image (still terminates with NSAssert - 'image is nil'). Any help or suggestions will be greatly appreciated. Thanks

    Read the article

  • Handling out of memory errors in iPhone

    - by hgpc
    I would like to handle out of memory errors in iPhone to execute logic with lesser memory requirements in case I run of of memory. In particular, I would like to do something very similar to the followin pseudo-code: UIImage* image; try { image = [UIImage imageNamed:@"high_quality_image.png"]; } catch (OutOfMemoryException e) { image = [UIImage imageNamed:@"low_quality_image.jpg"]; } First I attempt to load a high-quality image, and if I run out of memory while doing it, then I use a lower quality image. Would this be possible?

    Read the article

  • UIImage color changing?

    - by senthilmuthu
    hi, how can i change the UIImage's Color through Programming,any help pls?if i send UIImage, its color must be changed ..any help please? if i change rgb color like the following through bitmaphandling it did not work.i have given blackcolor's RGB value like 0,0,0.....

    Read the article

  • NSData dataWithContentsOfURL

    - by ketan rajput
    I have this method for button click (download). The problem is that it is terminating due to an exception: [Session started at 2011-03-14 13:06:45 +0530.] 2011-03-14 13:06:45.710 XML[7079:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString isFileURL]: unrecognized selector sent to instance 0x62b8' -(IBAction) download { UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:@"http://ws.cdyne.com/WeatherWS/Images/thunderstorms.gif"]]; [image release]; } What is the problem?

    Read the article

  • Why do I not get low memory issues until images are draw on the screen?

    - by maxpower
    I am able to load over 200 UIImage objects into a NSMutableDictionary without any memorry warning issues. When I start displaying them on the screen (after about showing 10-20 images) I get low memory warnings and an eventual crash. Only about 8 images are displayed at anyone time. Does it take additional memory to actually draw a UIImage on the screen? No memory leaks are showing up and i've reviewed code for leaks many many times.

    Read the article

  • Editing an UIImage

    - by wwrob
    I have an UIImage that I want to edit (say, make every second row of pixels black). Now I am aware of the functions that extract PNG or JPEG data from the image, but that's raw data and I have no idea how the png/jpeg files work. Is there a way I can extract the colour data from each pixel into an array? And then make a new UIImage using the data from the array?

    Read the article

  • Cant change text in custom cell

    - by darkman
    I created a custom cell to display a text a two images, when the user select the cell, the image is suposed to change, i can acess the properties of the cell, but cant change then : - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; CustomCell *cell = (CustomCell *)[self.tableView cellForRowAtIndexPath:indexPath]; cell.check.image = setImage:[UIImage imageNamed:@"1355327732_checkbox-checked"]; [cell.check setImage:[UIImage imageNamed:@"1355327732_checkbox-checked"]]; } cell.check is a UIImageView Am i missing something?

    Read the article

  • UIImageView doesn't update with my image

    - by Sheehan Alam
    I am trying to set my image: detailedEventViewController.thumbnail.image = [UIImage imageNamed:@"amnesia.png"]; But the imageview appears blank. amnesia.png is in my resources group. The file exists. Results of my log: 2011-01-08 10:52:32.822 HD Pocket Vacations[25271:207] Image: <UIImage: 0x66203b0> 2011-01-08 10:52:32.823 HD Pocket Vacations[25271:207] dEVC: <DetailedEventViewController: 0x6628340> 2011-01-08 10:52:32.824 HD Pocket Vacations[25271:207] thumbnail: (null)

    Read the article

  • UIImage Fade in after load on my UITable

    - by Cy
    I have an UIImage that loads from the web, and I'd like it to fade in when it displays in my UITableCell. if([thumb image]) { UIImage *imagen = [thumb.image retain]; [imagen drawInRect:CGRectMake(15, 4, 44, 44)]; [imagen release]; } How could I achieve it?

    Read the article

  • Define background Image with UIImage

    - by Wohoo Summer
    I am using header file to set the background for my application and I have something like #define backgroundImage [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpeg"]] but I want use UIImageView instead of UIColor. I know I can do: UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480) [imageView setImage:[UIImage imageNamed:@"background.png"]]; self.tableView.backgroundView = imageView; but how do I use it with #define?

    Read the article

  • [obj-c] autorelease problem

    - by BQuadra
    Why the NSArray allocated with arrayWithObjects dealloc automatically if already used by BObject object?? in teory NSArray must remain allocated all the BObject life time... [[BObject alloc] initObjectName:@"oneObject" states: [NSArray arrayWithObjects: [[State alloc] initStateName:@"stand_front" singleImg:[NSArray arrayWithObjects:[UIImage imageNamed:@"front_1.png"], nil]], [[State alloc] initStateName:@"front_walking" frames: [NSArray arrayWithObjects: [UIImage imageNamed:@"front_1.png"], [UIImage imageNamed:@"front_2.png"], [UIImage imageNamed:@"front_3.png"], [UIImage imageNamed:@"front_4.png"], [UIImage imageNamed:@"front_5.png"], [UIImage imageNamed:@"front_6.png"], [UIImage imageNamed:@"front_7.png"], [UIImage imageNamed:@"front_8.png"], nil] duration:0.8 repeat:0], nil] isSolid:TRUE];

    Read the article

  • iPhone SDK background thread image loading problem

    - by retailevolved
    I have created a grid view that displays six "cells" of content. In each cell, an image is loaded from the web. There are a multiple pages of this grid (the user moves through them by swiping up / down to see the next set of cells). Each cell has its own view controller. When these view controllers load, they use an ImageLoader class that I made to load and display an image. These view controllers implement an ImageLoaderDelegate that has a single method that gets called when the image is finished loading. ImageLoader does its work on a background thread and then simply notifies its delegate when it is done loading, passing the image to the delegate method. Trouble is that if the user moves on to the next page of grid content before the image has finished loading (releasing the GridCellViewControllers that use the ImageLoaders), the app crashes. I suspect that this is because along the line, an asynchronous method finishes and attempts to notify its delegate but can't because it's been released. Here's some code to give a better picture: GridCellViewController.m: - (void)viewDidLoad { [super viewDidLoad]; // ImageLoader _loader = [[ProductImageLoader alloc] init]; _loader.delegate = self; if(_boundObject) [_loader loadImageForProduct:_boundObject]; } //ImageLoaderDelegate method - (void) imageDidFinishLoading: (UIImage *)image { [_imgController setImage:image]; } ProductImageLoader.m - (void) loadImageForProduct: (Product *) product { // Get image on another thread [NSThread detachNewThreadSelector:@selector(getImageForProductInBackground:) toTarget:self withObject:product]; } - (void) getImageForProductInBackground: (Product *) product { NSAutoreleasePool *tempPool = [[NSAutoreleasePool alloc] init]; HttpRequestLoader *tempLoader = [[HttpRequestLoader alloc] init]; NSURL *tempUrl = [product getImageUrl]; NSData *imageData = tempUrl ? [tempLoader loadSynchronousDataFromAddress:[tempUrl absoluteString]] : nil; UIImage *image = [[UIImage alloc] initWithData:imageData]; [tempPool release]; if(delegate) [delegate imageDidFinishLoading:image]; } The app crashes with EXC_BAD_ACCESS. Disclaimer: The code has been slightly modified to focus on the issue at hand.

    Read the article

  • Covert uiiamge into string

    - by Warrior
    I am new iphone development.Is there any possibility to covert the uiimage into string and then once again back to image. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img1 editingInfo:(NSDictionary *)editInfo { [[picker parentViewController] dismissModalViewControllerAnimated:YES]; NSData *data = UIImagePNGRepresentation(img1); NSString *str1; str1 = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; MyAppAppDelegate *appDelegate = (MyAppAppDelegate *) [[UIApplication sharedApplication] delegate]; [appDelegate setCurrentLink:str1]; EmailPictureViewController *email = [[EmailPictureViewController alloc] initWithNibName:@"EmailPictureViewController" bundle:nil]; [self.navigationController pushViewController:email animated:YES]; } so i can use delegate methods to tranfer the image from one view to another view. so i should convert the string once again to image and display it in another view. In Another view - (void)viewDidLoad { MyAppAppDelegate *appDelegate =(MyAppAppDelegate *) [[UIApplication sharedApplication] delegate]; str1 = [appDelegate getCurrentLink]; NSLog(@"The String %@",str1); NSData *aData; aData = [str1 dataUsingEncoding: NSASCIIStringEncoding]; NSLog(@"The String Data %@",aData); NSLog(@"Inside Didload3"); [imgview setImage:[UIImage imageWithData:aData]]; } But this doesn't work for me.Where do i go wrong.Is there any way to solve it?.Please help me out.Thanks.

    Read the article

  • Can't draw UImage in UIView::drawRect

    - by Joel
    I know this seems like a simple task, which is why I don't understand why I can't get the image to render. When I set up my UIView, I do the following: myUiView.backgroundColor = [UIColor clearColor]; myUiView.opaque = NO; I create and retain the UIImage in the init function of my UIView: image = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"]] retain]; then my drawRect looks like this: - (void) drawRect:(CGRect) rect { [image drawInRect:self.bounds]; } Ultimately I'll be manipulating that UIImage via bitmap context, and then in drawRect create a CGImage out of the context, and render that, but for now I'm just trying to get it rendering a known image. I've been digging through this site, as well as the documentation. I've gone down the CG path and tried drawing it with CGContextDrawImage by following the numerous examples other people have posted, but that didn't work either. So I've come back to what seems to be the most straightforward way to draw an image, but it isn't working. Any help would be greatly appreciated. Thanks in advance.

    Read the article

  • Help with a loop to return UIImage from possible matches

    - by Canada Dev
    I am parsing a list of locations and would like to return a UIImage with a flag based on these locations. I have a string with the location. This can be many different locations and I would like to search this string for possible matches in an NSArray, and when there's a match, it should find the appropriate filename in an NSDictionary. Here's an example of the NSDictionary and NSArray: NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: @"franceFlag", @"france", @"greeceFlag", @"greece", @"spainFlag", @"spain", @"norwayFlag", @"norway", nil]; NSArray *array = [NSArray arrayWithObjects: @"france" @"greece" @"spain" @"portugal" @"ireland" @"norway", nil]; Obviously I'll have a lot more countries and flags in both. Here's what I have got to so far: -(UIImage *)flagFromOrigin:(NSString *)locationString { NSRange range; for (NSString *arrayString in countryArray) { range = [locationString rangeOfString:arrayString]; if (range.location != NSNotFound) { return [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[dictionary objectForKey: arrayString] ofType:@"png"]]; } } return nil; } Now, the above doesn't actually work. I am missing something (and perhaps not even doing it right in the first place) The issue is, the locationString could have several locations in the same country, described something like this "Barcelona, Spain", "Madrid, Spain", "North Spain", etc., but I just want to retrieve "Spain" in this case. (Also, notice caps for each country). Basically, I want to search the locationString I pass into the method for a possible match with one of the countries listed in the NSArray. If/When one is found, it should continue into the NSDictionary and grab the appropriate flag based on the correct matched string from the array. I believe the best way would then to take the string from the array, as this would be a stripped-out version of the location. Any help to point me in the right direction for the last bit is greatly appreciated.

    Read the article

  • Saving UIImagePickerController images to Core Data without crashing

    - by Gordon Fontenot
    I have been trying to minimize my memory footprint with UIImagePickerController, but I'm starting to think that the memory problems I am having are resulting from poor memory management, instead of a particular way to handle the UIImagePickerController object. My workflow is this: The "Edit Image" button is clicked, which presents a UIActionSheet. This action sheet allows you to delete, take a picture, choose from the library, or cancel. If you select Choose from the library or Take Picture, I alloc an instance of UIImagePickerController and present it, followed by a release of UIImagePickerController: -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (actionSheet.tag != 999) { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; BOOL pickImage = nil; if (actionSheet.tag == iPhoneWithDelete) { switch (buttonIndex) { case 0: object.objectImage = nil; pickImage = NO; break; case 1: imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; pickImage = YES; break; case 2: imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; pickImage = YES; break; default: pickImage = NO; break; } } else if (actionSheet.tag == iPhoneNoDelete) { switch (buttonIndex) { case 0: imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; pickImage = YES; break; case 1: imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; pickImage = YES; break; default: pickImage = NO; break; } } else if (actionSheet.tag == iPodWithDelete) { switch (buttonIndex) { case 0: object.objectImage = nil; pickImage = NO; break; case 1: imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; pickImage = YES; break; default: pickImage = NO; break; } } else if (actionSheet.tag == iPodNoDelete) { switch (buttonIndex) { case 0: imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; pickImage = YES; break; default: pickImage = NO; break; } } if (pickImage) { imagePicker.allowsEditing = YES; [self presentModalViewController:imagePicker animated:YES]; } else { [self setupImageButton]; [self setupChooseImageButton]; } [imagePicker release]; } } Once I get a selection back from the UIImagePickerController, I save 2 images, a resized version of the edited image to use for a thumbnail, and a 800x600 version of the original unedited image into a relationship attribute (Transformational, using the same UIImage to PNG transformations found in the Recipes demo code) for display use: (the resize methods are based on the one demoed in this SO post.) - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self dismissModalViewControllerAnimated:YES]; NSManagedObject *oldImage = object.imageFull; if (oldImage != nil) { [object.managedObjectContext deleteObject:oldImage]; } NSManagedObject *image = [NSEntityDescription insertNewObjectForEntityForName:@"Image" inManagedObjectContext:object.managedObjectContext]; object.imageFull = image; UIImage *rawImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; CGSize size = CGSizeMake(800, 600); UIImage *fullImage = [UIImageManipulator scaleImage:rawImage toSize:size]; [image setValue:fullImage forKey:@"imageFull"]; UIImage *processedImage = [UIImageManipulator scaleImage:[info objectForKey:@"UIImagePickerControllerEditedImage"] toSize:CGSizeMake(75, 75)]; object.objectImage = processedImage; [self setupImageButton]; [self setupChooseImageButton]; rawImage = nil; fullImage = nil; processedImage = nil; } When I go through viewDidUnload I am setting self.object = nil, and [object release] during dealloc, but I'm still getting memory warnings after about 10 image changes, with a crash at around 20. It leads me to believe that I am not getting that full image out of memory the correct way. What am I missing here? And on a second note, does the Camera source use significantly more memory than the Photo Albums source? I tend to get more crashes when using the camera.

    Read the article

  • Application shows low memory warning and crashes while loading images?

    - by Bhoomi
    I am using following code for loading images from server using following code.When i scroll UITableView application crashes. AsynchrohousImageView class .m file - (void)dealloc { [connection cancel]; //in case the URL is still downloading [connection release]; [data release]; [_imageView release]; [_activityIndicator release]; [super dealloc]; } - (void)loadImageFromURL:(NSURL*)url defaultImageName:(NSString *)defaultImageName showDefaultImage:(BOOL)defaultImageIsShown showActivityIndicator:(BOOL)activityIndicatorIsShown activityIndicatorRect:(CGRect)activityIndicatorRect activityIndicatorStyle:(UIActivityIndicatorViewStyle)activityIndicatorStyle { if (connection!=nil) { [connection release]; } if (data!=nil) { [data release]; } if ([[self subviews] count]>0) { [[[self subviews] objectAtIndex:0] removeFromSuperview]; // } if (defaultImageIsShown) { self.imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:defaultImageName]] autorelease]; } else { self.imageView = [[[UIImageView alloc] init] autorelease]; } [self addSubview:_imageView]; _imageView.frame = self.bounds; [_imageView setNeedsLayout]; [self setNeedsLayout]; if (activityIndicatorIsShown) { self.activityIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:activityIndicatorStyle] autorelease]; [self addSubview:_activityIndicator]; _activityIndicator.frame = activityIndicatorRect; _activityIndicator.center = CGPointMake(_imageView.frame.size.width/2, _imageView.frame.size.height/2); [_activityIndicator setHidesWhenStopped:YES]; [_activityIndicator startAnimating]; } NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; } - (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)incrementalData { if (data==nil) { data = [[NSMutableData alloc] initWithCapacity:2048]; } [data appendData:incrementalData]; } - (void)connectionDidFinishLoading:(NSURLConnection*)theConnection { [connection release]; connection=nil; _imageView.image = [UIImage imageWithData:data]; if (_activityIndicator) { [_activityIndicator stopAnimating]; } [data release]; data=nil; } - (UIImage*) image { UIImageView* iv = [[self subviews] objectAtIndex:0]; return [iv image]; } In ViewController Class Which loads image - (UITableViewCell *)tableView:(UITableView *)tV cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *reuseIdentifier =@"CellIdentifier"; ListCell *cell = (ListCell *)[tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; if (cell==nil) { cell = [[ListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]; NSMutableDictionary *dicResult = [arrResults objectAtIndex:indexPath.row]; NSURL *url=[NSURL URLWithString:[dicResult objectForKey:@"Image"]]; AsynchronousImageView *asyncImageView = [[AsynchronousImageView alloc] initWithFrame:CGRectMake(5, 10,80,80)]; [asyncImageView loadImageFromURL:url defaultImageName:@"DefaultImage.png" showDefaultImage:NO showActivityIndicator:YES activityIndicatorRect:CGRectMake(5, 10,30,30) activityIndicatorStyle:UIActivityIndicatorViewStyleGray]; // load our image with URL asynchronously [cell.contentView addSubview:asyncImageView]; // cell.imgLocationView.image = [UIImage imageNamed:[dicResult valueForKey:@"Image"]]; [asyncImageView release]; } if([arrResults count]==1) { UITableViewCell *cell1=[tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; if(cell1==nil) cell1=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier] autorelease]; NSMutableDictionary *dicResult = [arrResults objectAtIndex:0]; cell1.textLabel.text=[dicResult valueForKey:@"NoResults"]; return cell1; } else { NSMutableDictionary *dicResult = [arrResults objectAtIndex:indexPath.row]; NSString *title = [NSString stringWithFormat:@"%@ Bedrooms-%@", [dicResult valueForKey:KEY_NUMBER_OF_BEDROOMS],[dicResult valueForKey:KEY_PROPERTY_TYPE]]; NSString *strAddress = [dicResult valueForKey:KEY_DISPLAY_NAME]; NSString *address = [strAddress stringByReplacingOccurrencesOfString:@", " withString:@"\n"]; NSString *price = [dicResult valueForKey:KEY_PRICE]; NSString *distance = [dicResult valueForKey:KEY_DISTANCE]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.lblTitle.text = title; cell.lblAddress.text = address; if ([price length]>0) { cell.lblPrice.text = [NSString stringWithFormat:@"£%@",price]; }else{ cell.lblPrice.text = @""; } if ([distance length]>0) { cell.lblmiles.text = [NSString stringWithFormat:@"%.2f miles",[distance floatValue]]; }else{ cell.lblmiles.text = @""; } } return cell; } How can i resolve this? I have attached heapshot analysis screen shot of it.Here non Object consumes so much of memory what is that?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >