Search Results

Search found 530 results on 22 pages for 'uiimageview'.

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

  • UIImagePickerController Save to Disk then Load to UIImageView

    - by Harley Gagrow
    Hi, I have a UIImagePickerController that saves the image to disk as a png. When I try to load the PNG and set a UIImageView's imageView.image to the file, it is not displaying. Here is my code: (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; NSData *imageData = UIImagePNGRepresentation(image); // Create a file name for the image NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeStyle:NSDateFormatterShortStyle]; [dateFormatter setDateStyle:NSDateFormatterShortStyle]; NSString *imageName = [NSString stringWithFormat:@"photo-%@.png", [dateFormatter stringFromDate:[NSDate date]]]; [dateFormatter release]; // Find the path to the documents directory NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // Now we get the full path to the file NSString *fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName]; // Write out the data. [imageData writeToFile:fullPathToFile atomically:NO]; // Set the managedObject's imageLocation attribute and save the managed object context [self.managedObject setValue:fullPathToFile forKey:@"imageLocation"]; NSError *error = nil; [[self.managedObject managedObjectContext] save:&error]; [self dismissModalViewControllerAnimated:YES]; } Then here is how I try to load it: self.imageView.backgroundColor = [UIColor lightGrayColor]; self.imageView.frame = CGRectMake(10, 10, 72, 72); if ([self.managedObject valueForKey:@"imageLocation"] != nil) { NSLog(@"Trying to load the imageView with: %@", [self.managedObject valueForKey:@"imageLocation"]); UIImage *image = [[UIImage alloc] initWithContentsOfFile:[self.managedObject valueForKey:@"imageLocation"]]; self.imageView.image = image; } else { self.imageView.image = [UIImage imageNamed:@"no_picture_taken.png"]; } I get the message that it's trying to load the imageView in the debugger, but the image is never displayed in the imageView. Can anyone tell me what I've got wrong here? Thanks a bunch.

    Read the article

  • iOS UIImageView dataWithContentsOfURL returning empty

    - by user761389
    I'm trying to display an image from a URL in a UIImageView and I'm seeing some very peculiar results. The bit of code that I'm testing with is below imageURL = @"http://images.shopow.co.uk/image/user_dyn/1073/32/32"; imageURL = @"http://images.shopow.co.uk/assets/profile_images/default/32_32/avatar-male-01.jpg"; NSURL *imageURLRes = [NSURL URLWithString:imageURL]; NSData *imageData = [NSData dataWithContentsOfURL:imageURLRes]; UIImage *image = [UIImage imageWithData:imageData]; NSLog(@"Image Data: %@", imageData); In it's current form I can see data in the output window which is what I'd expect. However if comment out the second imageURL so I'm referencing the first I'm getting empty data and therefore nil is being returned by imageWithData. What is possibly more confusing is that the first image is basically the same as the second but it's been through a PHP processing script. I'm nearly certain that it isn't the script that's causing the issue because if I use this instead imageURL = @"http://images.shopow.co.uk/image/product_dynimg/389620/32/32" the image is displayed and this uses the same image processing script. I'm struggling to find any difference in the images that would cause this to occur. Any help would be appreciated.

    Read the article

  • Change UIImageView Center - iPhone

    - by CccTrash
    I am trying to make a little ball that rolls around based on the accelerometer values in the iPhone. This code will not build: -(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { if(difficulty == @"easy") { CGFloat newX = (CGFloat)(ball.center.x + (CGFloat)acceleration.x); CGFloat newY = (CGFloat)(ball.center.y + (CGFloat)acceleration.y); ball.center.x = newX; ball.center.y = newY; } } It gives me an lvalue required as left operand of assignment error. I've tried 100 different things and I fail every time...This is just the latest failure. Anyone have any insight?

    Read the article

  • iPhone smooth move and pinch of UIImageView

    - by Jacob
    I have an image view that I'm wanting to be able to move around, and pinch to stretch it. It's all working, but it's kinda jumpy when I start to do any pinch movements. The position will jump back and forth between the two fingers. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { startLocation = [[touches anyObject] locationInView:mouth_handle]; if([touches count] == 2) { NSArray *twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; UITouch *second = [twoTouches objectAtIndex:1]; initialDistance = distanceBetweenPoints([first locationInView:mouth_handle],[second locationInView:mouth_handle]); } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint pt = [[touches anyObject] locationInView:mouth_handle]; CGRect frame = [mouth_handle frame]; frame.origin.x += pt.x - startLocation.x; frame.origin.y += pt.y - startLocation.y; frame.origin.x = (frame.origin.x < 58) ? 58 : frame.origin.x; frame.origin.x = (frame.origin.x > (260 - mouth_handle.frame.size.width)) ? (260 - mouth_handle.frame.size.width) : frame.origin.x; frame.origin.y = (frame.origin.y < 300) ? 300 : frame.origin.y; frame.origin.y = (frame.origin.y > 377) ? 377 : frame.origin.y; if(frame.origin.x - prevDistanceX > 2 && frame.origin.x - prevDistanceX < -2) frame.origin.x = prevDistanceX; if(frame.origin.y - prevDistanceY > 2 && frame.origin.y - prevDistanceY < -2) frame.origin.y = prevDistanceY; prevDistanceX = frame.origin.x; prevDistanceY = frame.origin.y; CGFloat handleWidth = mouth_handle.frame.size.width; if([touches count] == 2) { NSArray *twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; UITouch *second = [twoTouches objectAtIndex:1]; CGFloat currentDistance = distanceBetweenPoints([first locationInView:mouth_handle],[second locationInView:mouth_handle]); handleWidth = mouth_handle.frame.size.width + (currentDistance - initialDistance); handleWidth = (handleWidth < 60) ? 60 : handleWidth; handleWidth = (handleWidth > 150) ? 150 : handleWidth; if(initialDistance == 0) { initialDistance = currentDistance; } initialDistance = currentDistance; } mouth_handle.frame = CGRectMake(frame.origin.x, frame.origin.y, handleWidth, 15); } Any thoughts on how to make this smoother?

    Read the article

  • Save a UIImageView using NSUSerDefaults

    - by Magician Software
    How do you save an Image using NSUSerDefaults The main image is set in IB, the secondary image is set here - (IBAction)changeImage { CATransition *fadeThing = [CATransition animation]; fadeThing.type = kCATransitionFade; fadeThing.subtype = kCATransitionFade; fadeThing.duration = 1; [CATransaction begin]; [background.layer addAnimation:fadeThing forKey:@"superCoolSloMoFadingAnimation"]; [background setImage:[UIImage imageNamed:@"Mainbackground.png"]]; [CATransaction commit]; I will have different actions for different images. Anyway of setting this up so I can use a toggle button maybe and change the image as well as save it Thanks

    Read the article

  • Scrolling png with text & alpha on top of a static UIImageView

    - by heymon
    I have a view controller that has a view structure as follows: FilesOwner FirstResponder View ImageView (.jpg) ScrollView ImageView (.png) The text in the innermost imageview has white text and clear (alpha) all around. I want to scroll the innermost imageview, and see the background image (the .jpg) behind it. Its not working. Its acting like the scrollview background obscures the underneath .jpg. I say this because if I change the background color of the scrollview, that's what I see i.e. if I set it black, I see black behind my .png, if I set it white, I see white. If I change the alpha of the scrollview that doesn't seem to work either. The one other thing I tried was unchecking drawing: Opaque, but that doesn't get it either.

    Read the article

  • Sometimes UIImageView seems to reject the image taken with iPhone Camera

    - by maxbareis
    Hi, it is very strange, because this error doesn't happen all the time... I have the following code: - (IBAction)getPhoto:(id)sender { UIImagePickerController * picker = [[UIImagePickerController alloc] init]; picker.delegate = self; #if TARGET_IPHONE_SIMULATOR picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; #else picker.sourceType = UIImagePickerControllerSourceTypeCamera; #endif [self presentModalViewController:picker animated:YES]; } with the corresponding delegated selector - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *image = [[info objectForKey:@"UIImagePickerControllerOriginalImage"] imageByScalingToSize:CGSizeMake(480, 320)]; [[self imageView] setImage:image]; [picker dismissModalViewControllerAnimated:YES]; } strange thing is, somtimes the image appears in imageView and sometimes not. I have called (gdb) po UIImagePNGRepresentation(image) right after setImage and stuffed the output into a file. The file is a perfect png. Has anyone experienced the same? Has anyone found a solution for it? Thanks in advance Max

    Read the article

  • IB not responding to UIImageView moving

    - by Rudiger
    This an incredibly annoying bug. I had a imageView and 2 Labels in a customCell nib. I changed the locations of all of them in the nib and the labels moved, view didn't. I've cleaned my targets, deleted everything relating to it the library, deleted the cell completely, reset the simulator, built it on a different target (3.1.2) and it still compiles the image in the same stupid spot. Can anyone help this is nuts. Sorry for being blunt but completely frustrated. Edit: I have deleted the nib and created it over again by hand, but with the same names. Doesn't fix it. I've checked to see if im moving it somewhere in the code and no dice.

    Read the article

  • UIImageView animation has long delay on device

    - by jiunhong
    I create a 5-frame animation on UImageView and each image is created by [UIImage imageWithContentOfFile:xxx], however, the animation on simulator is working well but not on device, it usually has ~1 sec delay though the animation duration is 1sec. Is anyway to preload the images involved in the animation? thanks.

    Read the article

  • iPhone: Strange Movement of Two UIImageView "Sprites"

    - by David Pollak
    I have two UIImageViews moving like sprites on a superview. Each imageview moves properly by itself but when I put both imageviews on the superview at the same time, their individual movement becomes strangely restricted to two different areas of the screen. They will not touch even programmed to the same coordinates. This is my movement code for the first imageView: - (void)viewDidLoad { [super viewDidLoad]; pos = CGPointMake(14.0, 7.0); [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES]; } - (void) onTimer { pallone.center = CGPointMake(pallone.center.x+pos.x, pallone.center.y+pos.y); if(pallone.center.x > 320 || pallone.center.x < 0) pos.x = -pos.x; if(pallone.center.y > 480 || pallone.center.y < 0) pos.y = -pos.y; } and for the second imageview: - (IBAction)spara{ cos = CGPointMake(8.0, 4.0); [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(inTimer) userInfo:nil repeats:YES]; } - (void)inTimer{ bomba.center = CGPointMake(bomba.center.x+pos.x, bomba.center.y+pos.y); if(bomba.center.x > 50 || bomba.center.x < 0) pos.x = -pos.x; if(bomba.center.y > 480 || bomba.center.y < 0) pos.y = -pos.y; } Why causes this strange behavior? Thanks for your help. I am a newbie.

    Read the article

  • UIImageView Centering Problem.

    - by sagar
    To understand my problem let's follow this steps. Open - XCode - New Project - View based application. Open View Controller.xib file. Drag an image-view into viewController's view. Place that image view on center of viewController's view. Apply size of 125x125 to image-view. Take any image with dimension of 320 width & 460 height. Drag that image into your application resources directory. Now, Again back to .xib File & select image-view Set image (which is in your resources) to image-view Set Image-view Mode to - Center Ok. Let me explain the situation now. after performing all above steps - image-view has an image which is larger than image-view's size. However, Image-view places that image on center & in View controller image-view is looking proper ( not scaled ). But When you run your application, image-view will be displayed in size of 320x460. ( but it is not actually scaled. ) Now, I can't find the reason, why interface builder is displaying something else & simulator/iphone is displaying something else ? My Query. I want the image's center portion within image-view no matter what image size is. Thanks in advance for sharing your knowledge. Sagar.

    Read the article

  • Show image from url in uiimageview

    - by skiria
    I try to show a image in my iphone app but it doesn't show. I connect in IB and I check to show a local image, it workd good. I also check the url from image and it is ok. I use the next code: NSURL *imageURL = [NSURL URLWithString: aVideo.urlThumbnail]; NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; UIImage *image = [UIImage imageWithData:imageData]; imageView.image = image; and //Video.h NSString *urlThumbnail; and this is my code on the view. - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [tableView reloadData]; } - (void)viewDidLoad { [super viewDidLoad]; NSURL *imageURL = [NSURL URLWithString: aVideo.urlThumbnail]; NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; UIImage *image = [UIImage imageWithData:imageData]; imageView.image = image; }

    Read the article

  • Layers of Images using UIImageView

    - by Taimur Hamza
    Hi everyone, I just wanted to confirm, is it possible that we add layers of images using UImageView, one as background and other on top of it. I mean i want to use 2 images one has to be in the background and the other on top of it. ( the size of both these images is 320 x 480 ). Through the attributes inspector we cant do it. Is there any we can do it through code. Maybe using subview or something. Thanks Geeks :) Taimur Ajmal

    Read the article

  • Cannot change UIImageView frame in a custom table cell.

    - by jkally
    I have a custom table cell. In it I have put (via the IB) an image view of a certain frame In 'cellForRowAtIndexPath', under certain conditions, I would like to modify the frame of this UIImageView, so I write something like: UIImageView *imgv = (UIImageView *)[cell viewWithTag:1]; CGRect r = CGRectMake(20.0, 20.0, 10.0, 10.0); imgv.frame = r; But nothing expected happens (The frame does move a little though not to where I want, but doesn't change its size at all);

    Read the article

  • Problem in Rendering images in UIImageView in iPhone programming.

    - by suse
    Hello, I've a UIViewController and a UIImageView, on UIImageView i want to flip between 2 images, which i'm not able to achieve. This is the code i've written, plz correct me if i'm wrong. UIViewController* VC = [[UIViewController alloc]init]; VC.view.backgroundColor = [UIColor redColor]; UIImageView* imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,320,400)]; [imgView setImage:[UIImage imageNamed:@"Image_A.jpg"]]; [VC.view addSubview:imgView]; sleep(2); [imgView setImage:[UIImage imageNamed:@"Image_B.jpg"]]; [VC.view addSubview:imgView]; [window addSubview:VC.view]; so when i execute this project, only Image_B is displayed on screen, while i want Image_A to be displayed then on sleep(2), Image_B has to be displayed. How would i make it possible?? plz guide me.. I'm struggling with this problem since 3days .. plz try to help me out... Thank You.

    Read the article

  • How can I detect touch events on a UIImageView inside a deep hierarchy of UIViews?

    - by jester
    I am developing a simple game on iPhone and I started with a View based application, and through the UIViewController I am loading a custom UIView that contains some more UIViews and some UIImageViews. I want to detect touch events on some of the UIImageViews, but I wasn't able so far. I've created a second project for testing purposes and figured that UIImageViews handle touch events when the hierarchy is like : UIViewController - UIView - UIImageView, but when it's like : UIViewController - UIView - UIView - UIImageView they are not detected. Notes: - userInteractionEnabled is YES in all cases - all UIViews and UIImageViews I mention above are custom subclasses. Can you think of any reason why, when a custom UIImageView gets deeper in the view hierarchy can't receive touch events?

    Read the article

  • Why does UIImageView "darken"/saturate PNG images, and can I stop it?

    - by Ben
    I have a PNG file in a UIImageView, and next to that I have an EAGLView which displays the continuation of that same image (long story) as a texture, carved from the same original PNG. The point is, that these images, which should match up flawlessly, actually have somewhat differing color saturation. Normally I'd blame my handling of the PNG texture load in GL, but when I hold Preview (with the PNG) up to the iPhone simulator, it's GL that's spot on, and the UIImageView that's wrong! It's taken the image and made it ever-so-slightly more saturated. The image view is opaque with 100% alpha. I verified this on a clean UIImageView with another PNG file when put next to Preview. Anyone know what's up?

    Read the article

  • Is there any reason why we don't use subclasses of UIImageView ?

    - by gotye
    Hey everyone, I am currently trying to create a subclass of UIImageView in order to make it download its image from server asynchronously ;) I tried to do it by myself but I haven't gone very far yet :D Anyway, I looked around here and found this : AsyncImageDownload I had a look at the code and the first which springs to mind is : why subclassing a UIView and not a UIImageView ?!? Any thoughts ? Cheers mates, Gotye.

    Read the article

  • How to get rid of previous reflection when reflecting a UIImageView (with changing pictures)?

    - by epale
    Hi everyone, I have managed to use the reflection sample app from apple to create a reflection from a UIImageView. But the problem is that when I change the picture inside the UIImageView, the reflection from the previous displayed picture remains on the screen. The new reflection on the next picture then overlaps the previous reflection. How do I ensure that the previous reflection is removed when I change to the next picture? Thank you so much. I hope my question is not too basic. Here is the codes which i used so far: //reflection self.view.autoresizesSubviews = YES; self.view.userInteractionEnabled = YES; // create the reflection view CGRect reflectionRect = currentView.frame; // the reflection is a fraction of the size of the view being reflected reflectionRect.size.height = reflectionRect.size.height * kDefaultReflectionFraction; // and is offset to be at the bottom of the view being reflected reflectionRect = CGRectOffset(reflectionRect, 0, currentView.frame.size.height); reflectionView = [[UIImageView alloc] initWithFrame:reflectionRect]; // determine the size of the reflection to create NSUInteger reflectionHeight = currentView.bounds.size.height * kDefaultReflectionFraction; // create the reflection image, assign it to the UIImageView and add the image view to the containerView reflectionView.image = [self reflectedImage:currentView withHeight:reflectionHeight]; reflectionView.alpha = kDefaultReflectionOpacity; [self.view addSubview:reflectionView]; //reflection */ Then the codes below are used to form the reflection: CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh) { CGImageRef theCGImage = NULL; // gradient is always black-white and the mask must be in the gray colorspace CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); // create the bitmap context CGContextRef gradientBitmapContext = CGBitmapContextCreate(nil, pixelsWide, pixelsHigh, 8, 0, colorSpace, kCGImageAlphaNone); // define the start and end grayscale values (with the alpha, even though // our bitmap context doesn't support alpha the gradient requires it) CGFloat colors[] = {0.0, 1.0, 1.0, 1.0}; // create the CGGradient and then release the gray color space CGGradientRef grayScaleGradient = CGGradientCreateWithColorComponents(colorSpace, colors, NULL, 2); CGColorSpaceRelease(colorSpace); // create the start and end points for the gradient vector (straight down) CGPoint gradientStartPoint = CGPointZero; CGPoint gradientEndPoint = CGPointMake(0, pixelsHigh); // draw the gradient into the gray bitmap context CGContextDrawLinearGradient(gradientBitmapContext, grayScaleGradient, gradientStartPoint, gradientEndPoint, kCGGradientDrawsAfterEndLocation); CGGradientRelease(grayScaleGradient); // convert the context into a CGImageRef and release the context theCGImage = CGBitmapContextCreateImage(gradientBitmapContext); CGContextRelease(gradientBitmapContext); // return the imageref containing the gradient return theCGImage; } CGContextRef MyCreateBitmapContext(int pixelsWide, int pixelsHigh) { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); // create the bitmap context CGContextRef bitmapContext = CGBitmapContextCreate (nil, pixelsWide, pixelsHigh, 8, 0, colorSpace, // this will give us an optimal BGRA format for the device: (kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst)); CGColorSpaceRelease(colorSpace); return bitmapContext; } (UIImage *)reflectedImage:(UIImageView *)fromImage withHeight:(NSUInteger)height { if (!height) return nil; // create a bitmap graphics context the size of the image CGContextRef mainViewContentContext = MyCreateBitmapContext(fromImage.bounds.size.width, height); // offset the context - // This is necessary because, by default, the layer created by a view for caching its content is flipped. // But when you actually access the layer content and have it rendered it is inverted. Since we're only creating // a context the size of our reflection view (a fraction of the size of the main view) we have to translate the // context the delta in size, and render it. // CGFloat translateVertical= fromImage.bounds.size.height - height; CGContextTranslateCTM(mainViewContentContext, 0, -translateVertical); // render the layer into the bitmap context CALayer *layer = fromImage.layer; [layer renderInContext:mainViewContentContext]; // create CGImageRef of the main view bitmap content, and then release that bitmap context CGImageRef mainViewContentBitmapContext = CGBitmapContextCreateImage(mainViewContentContext); CGContextRelease(mainViewContentContext); // create a 2 bit CGImage containing a gradient that will be used for masking the // main view content to create the 'fade' of the reflection. The CGImageCreateWithMask // function will stretch the bitmap image as required, so we can create a 1 pixel wide gradient CGImageRef gradientMaskImage = CreateGradientImage(1, height); // create an image by masking the bitmap of the mainView content with the gradient view // then release the pre-masked content bitmap and the gradient bitmap CGImageRef reflectionImage = CGImageCreateWithMask(mainViewContentBitmapContext, gradientMaskImage); CGImageRelease(mainViewContentBitmapContext); CGImageRelease(gradientMaskImage); // convert the finished reflection image to a UIImage UIImage *theImage = [UIImage imageWithCGImage:reflectionImage]; // image is retained by the property setting above, so we can release the original CGImageRelease(reflectionImage); return theImage; } */

    Read the article

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