Search Results

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

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

  • Objective C : UIButton image with NSArray in a random order

    - by Sarah
    Brief Idea about the flow : I have say minimum 1 and maximum 18 records in my database with a text and an image from which I have to fetch images and place any 3 of the same randomly to 3 UIButtons among which one image should match with my question. i.e. 1 is the answer and other 2 are the distractors. For Example : Question is : where is Apple? Now among the bunch of images, I want to place any 3 images on the 3 UIButtons(1 answer i.e. An Apple and 2 distractors) in a random order and on selecting the UIButton it should prompt me if it's a right answer or not. I am implementing below code for placing the UIImages in a random order : -(void) placeImages { NSMutableArray *images = [NSMutableArray arrayWithArray:arrImg]; NSArray *buttons = [NSArray arrayWithObjects:btn1,btn2,btn3, nil]; for (UIButton *btn in buttons) { int randomIndex= random() % images.count; UIImage *img = [images objectAtIndex:randomIndex]; [btn setImage:img forState:UIControlStateNormal]; [images removeObjectAtIndex:randomIndex]; } } But I am stuck at a point that how should I get 1 UIButton image with an answer and other as distractors also that how should i maintain the index of the image from the NSArray? Kindly guide me. Thank you.

    Read the article

  • Reason why UIImageView gives me a 'distorted' image sometimes

    - by Cedric Vandendriessche
    I have a custom UIView with a UILabel and a UIImageView subview. (tried using UIImageView subclass aswell). I assign an image to it and add the view to the screen. I wrote a function which adds the amount of LetterBoxes to the screen as there are letters in the word: - (void)drawBoxesForWord:(NSString *)word { if(boxesContainer == nil) { /* Create a container for the LetterBoxes (animation purposes) */ boxesContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 205, 320, 50)]; [self.view addSubview:boxesContainer]; } /* Calculate width of letterboxes */ NSInteger numberOfCharacters = [word length]; CGFloat totalWidth = numberOfCharacters * 28 + (numberOfCharacters - 1) * 3; CGFloat leftCap = (320 - totalWidth) / 2; [letters removeAllObjects]; /* Draw the boxes to the screen */ for (int i = 0; i < numberOfCharacters; i++) { LetterBox *letter = [[LetterBox alloc] initWithFrame:CGRectMake(leftCap + i * 31 , 0, 28, 40)]; [letters addObject:letter]; [boxesContainer addSubview:letter]; [letter release]; }} This gives me the image below: http://www.imgdumper.nl/uploads2/4ba3b2c72bb99/4ba3b2c72abfd-Goed.png But sometimes it gives me this: imgdumper.nl/uploads2/4ba3b2d888226/4ba3b2d88728a-Fout.png I add them to the same boxesContainer but they first remove themselves from the superview, so it's not like you see them double or something. What I find weird is that they are all good or all bad.. This is the init function for my LetterBox: if (self == [super initWithFrame:aRect]) { /* Create the box image with same frame */ boxImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; boxImage.contentMode = UIViewContentModeScaleAspectFit; boxImage.image = [UIImage imageNamed:@"SpaceOpen.png"]; [self addSubview:boxImage]; /* Create the label with same frame */ letterLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; letterLabel.backgroundColor = [UIColor clearColor]; letterLabel.font = [UIFont fontWithName:@"ArialRoundedMTBold" size:26]; letterLabel.textColor = [UIColor blackColor]; letterLabel.textAlignment = UITextAlignmentCenter; [self addSubview:letterLabel]; } return self;} Does anyone have an idea why this could be? I'd rather have them display correctly every time :)

    Read the article

  • plus minus table View cell

    - by user1748387
    I have the following code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UIImage * i1 = [UIImage imageNamed: @"inc_01.png"]; UIImage * i2 = [UIImage imageNamed: @"inc_02.png"]; UIImage * i3 = [UIImage imageNamed: @"inc_04.png"]; UIImage * i5 = [UIImage imageNamed: @"inc_05.png"]; UIImage * i6 = [UIImage imageNamed: @"inc_06.png"]; UIImage * i7 = [UIImage imageNamed: @"inchd.png"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } if(indexPath.row == 0) { UIImageView * header= [[UIImageView alloc] initWithImage: i1]; cell.backgroundView = header; // Configure the cell… } else if (indexPath.row == 2) { UIImageView *backgroundCellImage=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 280, 11)]; backgroundCellImage.image=[UIImage imageNamed:@"inc_06.png"]; [cell.contentView addSubview:backgroundCellImage]; } else { // Configure the cell… UIImageView *imageView = [[UIImageView alloc] initWithImage: i3]; cell.textLabel.text = @"text"; UIImageView *backgroundCellImage=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 57, 46)]; backgroundCellImage.image=[UIImage imageNamed:@"inc_02.png"]; UIImageView *backgroundCellImage2=[[UIImageView alloc] initWithFrame:CGRectMake(223, 0, 57, 46)]; backgroundCellImage2.image=[UIImage imageNamed:@"inc_04.png"]; UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(57, 0, 166, 46)]; label.text = @"wow"; [cell.contentView addSubview:backgroundCellImage]; [cell.contentView addSubview:backgroundCellImage2]; [cell.contentView addSubview:label]; } return cell; } that basically creates a table view and puts an image to the left and right of each cell. I want it so that people can click on the left or right image in each cell, and something different happens based on the cell number. So if they click on the left image for cell in row 1, a function gets call with the row number they clicked on, and an indicator telling me they clicked on the left image and not the right image. How can I do that using objective-c?

    Read the article

  • Animate move and scale of image UIButton

    - by Sam V
    I want it to be animated so I'm using [UIView beginAnimations] I've tried animating using button.imageView.frame (with image set as imageView) but it only animates the position, the image doesn't get scaled down at all. using hateButton.frame (when image is set as backgroundImage), the backgroundImage gets scaled down but it's not animated. How do I animate-scale a UIButton image?

    Read the article

  • UIImageView size becomes equal to the size of image it holds after autoresizing

    - by abura
    Hello, I faced a strange problem. My task is to provide scaling an image to fill the UIImageView frame. The UIImageView is a subview of another view. The code is following: CGRect frame=CGRectMake(0,0,viewSize.width,viewSize.height); UIView* backView=[[UIView alloc] initWithFrame:frame]; backView.autoresizesSubviews=YES; backView.autoresizingMask=UIViewAutoresizingFlexibleWidth; UIImageView* imgView=[[UIImageView alloc]initWithFrame:viewFrame]; imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; imgView.contentMode=UIViewContentModeScaleToFill; [subcellBackView addSubview:imgView]; [imgView release]; When the image arrives, it is assigned the the imgView: imgView.image=img; The image is scaled according to the imgView's size. Everything is all right until the iPhone (simulator) rotation. After first autoresizing the imgView size becomes equal to the image size (which is much greater) and overlaps its superview frame. The superview frame reacts properly to the orientation change. Could you please help?

    Read the article

  • How to set image to the UISegmentedControl in iphone?

    - by Warrior
    I am new to iphone development.I have created UISegmentedControl having 2 segments. I want to to display images for each segment instead of title.Here is my code NSArray *itemArray = [NSArray arrayWithObjects: @"segment1", @"segment2", nil]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; segmentedControl.frame = CGRectMake(5,100,300,40); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.selectedSegmentIndex = 1; [self.view addSubview:segmentedControl]; [segmentedControl release]; But instead of displaying the title ,segment1 and segment2 it should be replaced with the images i have.Please help me out.Thanks.

    Read the article

  • iPhone UIImage upload to web service

    - by user347635
    Hi all, I worked on this for several hours today and I'm pretty close to a solution but clearly need some help from someone who's pulled this off. I'm trying to post an image to a web service from the iPhone. I'll post the code first then explain everything I've tried: NSData *imageData = UIImageJPEGRepresentation(barCodePic, .9); NSString *soapMsg = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><WriteImage xmlns=\"http://myserver/imagewebservice/\"><ImgIn>%@</ImgIn></WriteImage></soap:Body></soap:Envelope>", [NSData dataWithData:imageData] ]; NSURL *url = [NSURL URLWithString:@"http://myserver/imagewebservice/service1.asmx"]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]]; [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:@"http://myserver/imagewebservice/WriteImage" forHTTPHeaderField:@"SOAPAction"]; [req addValue:msgLength forHTTPHeaderField:@"Content-Length"]; [req setHTTPMethod:@"POST"]; [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]]; conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; if (conn) { webData = [[NSMutableData data] retain]; } First thing, this code works fine for anything but an image. The web service is running on my local network and I can change the source code at will and if I change the "ImgIn" parameter to a string and pass a string in, everything works fine, I get a return value no problem. So there are no connectivity issues at all, I'm able to call and get data from this web service on this server no problems. But I need to upload an image to this web service via the ImgIn parameter, so the above code is my best shot so far. I also have didReceiveResponse, didReceiveData, didFailWithError, etc all being handled. The above code fires off didRecieveResponse every time. However didReceiveData is never fired and it's like the web service itself never even runs. When I debug the web service itself, it runs and debugs fine when I use a string parameter, but with the image parameter, it never even debugs when I call it. It's almost like the ImgIn parameter is too long (it's huge when I output it to the screen) and the web service just chokes on it. I've read about having to encode to Base64 when using this method, but I can't find any good links on how that's done. If that's what I'm doing wrong, can you PLEASE provide code as to how to do this, not just "you need to use Base64", I'd really appreciate it as I can find almost nothing on how to implement this with an example. Other than that, I'm kind of lost, it seems like I'm doing everything else right. Please help! Thanks

    Read the article

  • how to change UIKit UIImage:drawInRect method to AppKIt NSImage:drawInRect Method

    - by user322111
    Hi, i'm porting an iphone app to Mac app,there i have to change all the UIKit related class to AppKit. if you can help me on this really appreciate. is this the best way to do below part.. Iphone App--using UIKit UIGraphicsPushContext(ctx); [image drawInRect:rect]; UIGraphicsPopContext(); Mac Os--Using AppKit [NSGraphicsContext saveGraphicsState]; NSGraphicsContext * nscg = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]; [NSGraphicsContext setCurrentContext:nscg]; NSRect rect = NSMakeRect(offset.x * scale, offset.y * scale, scale * size.width, scale * size.height); [NSGraphicsContext restoreGraphicsState]; [image drawInRect:rect fromRect:NSMakeRect( 0, 0, [image size].width, [image size].height ) operation:NSCompositeClear fraction:1.0];

    Read the article

  • Asynchronous Image loading in certain custom UITableViewCells

    - by Dan
    So, I'm sure that this issue has been brought up before, but I haven't quite seen a solution for my specific problem. What I'm doing is loading a group of custom UITableViewCell's that are drawn using Loren Brichter's solution, each cell has some content, an icon (representing the user) that is asynchronously loaded into it, and a few other things. Eventually, I'm hoping to add support for images. Not every cell has an image, so in the creation of the cell, it determines if an image is required to be loaded and drawn into the cell. My problem is that I don't know how I can do that while keeping the image loaded asynchronously - with not every cell having the need to load an image (like needed with the icon) I'm not sure how to keep it in order when an cell is thrown off screen and re-rendered when the user scrolls over it. Each cell draws it content from an NSArray containing a custom object called FeedItem. All I'm really looking for is some sort of solution or idea to help me because right now I am at a loss. Thanks guys, I will appreciate the help.

    Read the article

  • how to "crop" a uiimage ?

    - by Yoot
    Hi, I'm making an app in which the user chooses an image, resize it by zooming (in a uiscrollview) and move it in the view. When finished, I would like to save the image like we can see it in the uiscrollview. Do you have any idea ? Thanks.

    Read the article

  • Blending Three Images into Graphics Context Using Alpha Blend Mode kBlendModeOverlay

    - by steganous
    Does kCGBlendModeOverlay not work exactly like Photoshop's Overlay blending mode? I'm trying to overlay three images into a graphic context via: [uiimageGreen drawAtPoint:CGPointMake(x, y) blendMode:kCGBlendModeOverlay alpha:1.0]; [uiimageRed drawAtPoint:CGPointMake(x, y) blendMode:kCGBlendModeOverlay alpha:1.0]; [uiimageBlue drawAtPoint:CGPointMake(x, y) blendMode:kCGBlendModeOverlay alpha:1.0]; In the end, if I overlay just two of the three, the result is much closer to my desired output color in places where both images intersect. Adding the third image, however, causes the first-drawn image's color to be dominant in the resulting mix of colors. (e.g. in the above code, green comes out dominant, when the result should actually be white) Do you get the same result if you try?

    Read the article

  • Overlaying 2D paths on UIImage without scaling artifacts

    - by tat0
    I need to draw a path along the shape of an image in a way that it is always matching its position on the image independent of the image scale. Think of this like the hybrid view of Google Maps where streets names and roads are superimposed on top of the aerial pictures. Furthermore, this path will be drawn by the user's finger movements and I need to be able to retrieve the path keypoints on the image pixel coordinates. The user zooms-in in order to more precisely set the paths location. I manage to somehow make it work using this approach: -Create a custom UIView called CanvasView that handles touches interaction and delivers scaling, rotation, translation values to either the UIImageView or PathsView (see bellow) depending on a flag: deliverToImageOrPaths. -Create a UIImageView holding the base image. This is set as a children of CanvasView -Create a custom UIView called PathsView that keeps track of the 2D paths geometry and draws itself with a custom drawRect. This is set as children of the UIImageView. So hierarchy: CanvasView - UIImageView -PathsView In this way when deliverToImageOrPaths is YES, finger gestures transforms both the UIImageView and its child PathsView. When deliverToImageOrPaths is NO the gestures affect only the PathsView altering its geometry. So far so good. QUESTION: The problem I have is that when scaling the base UIImageView (via its .transform property) the PathsView is scaled with aliasing artifacts. drawRect is still being called on the PathsView but I guess it's performing the drawing using the original buffer size and then interpolating. How can I solve this issue? Are there better ways to implement these features? PS: I tried changing the PathsView layer class to CATiledLayer with levelsOfDetailBias 4 and levelsOfDetail 4. It solves the aliasing problem to some extent but it's unacceptable slow to render.

    Read the article

  • How can get image from a path in to UITAbleViewCell ?

    - by srikanth rongali
    I have the following path in NSString *path1, /Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/snook.jpg How can I show the image snook.jpg. I need it to show in UITableViewCell for cell.imageView.image if path1 has the path. I used the following to get the last part of the path1 , snook.jpg. NSURL *url = [NSURL URLWithString:path1]; NSString *imageString = [url path]; But, url is showing as nil. How can I do it ? Thank you.

    Read the article

  • How to pull UIImages from NSData from a socket.

    - by Jus' Wondrin'
    Hey all! I'm using ASyncSocket to move some UIImages from one device over to another. Essentially, on one device I have: NSMutableData *data = UIImageJPEGRepresentation(image, 0.1); if(isRunning){ [sock writeData:data withTimeout:-1 tag:0]; } So a new image will be added to the socket every so often (like a webcam). Then, on the other device, I am calling: [listenSocket readDataWithTimeout:1 tag:0]; which will respond with: - (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { [responseData appendData:data]; [listenSocket readDataWithTimeout:1 tag:0]; } Essentially, what I want to be able to do is have an NSTimer going which will call @selector(PullImages): -(void) PullImages { In here, I want to be able to pull images out of ResponseData. How do I do that? There might not be a complete image yet, there might be multiple images, there might be one and a half images! I want to parse the NSData into each existing image! } Any assistance? Thanks in advance!

    Read the article

  • Vector graphics on iPhone

    - by burki
    Hello! How you can use EPS files within your UIView. What do I have to do to display for example a EPS on the iPhone's screen? Do I need to convert it first to a PDF (if yes, how?)? Or are there any other way to bring vector graphics onto the iPhone? That would be very nice. Thanks.

    Read the article

  • Preserving alpha issues with loaded UIImages - how to avoid discarding alpha values on import?

    - by Peter Hajas
    My application lets the user save/load images with alpha values to the camera roll on the device. I can see in the Photos application that these images are appropriately alpha'd, as alpha'd areas just appear black. However, when I load these images back into the application using the valueForKey:UIImagePickerControllerOriginalImage message to the info dictionary from (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info, the alpha values are turned to just white, making those sections opaque. Is there a way to preserve these alpha values?

    Read the article

  • iPhone: UIImageView not showing images

    - by George
    Hello, I've got UIImageView drawn in my nib-file and it's connected to a imageView iboutlet. I can load single pictures which will show up very nicely, but when it comes to drawing many images separately as like an animation, images won't show. I've got drawImage() function which takes NSData-objects(image data) and draws it to a screen(imageView). Main function has got for loop which loops 300 times as quickly as it can and each time it calls that drawImage function and passes different image data to it. Sometimes when I execute this code, last picture from that "animation" shows up, sometimes not at all. Maybe I need to schedule enough time for imageView so that the image can be shown? Hope someone has some clues. Thanks in advance!

    Read the article

  • capture image tag from multiple images

    - by Ruthy
    Hello, I have a .xib file containing 30 images and each image has a unique tag. How could I capture this tag in order to know which image has been touched when (void)touchesEnded??? How to define that images, on an array? Thanks for any idea to solve it!!

    Read the article

  • Inconsistent Frame / Bounds of UIImage and UIScrollView

    - by iFloh
    this one puzzles me. I have an Image with a width of 1600 pixels and height of 1819 pixels. I load the image as UIImageView into an UIScrollView and set the "contentsize parameter" iKarteScrollView.contentSize = CGSizeMake(iKarteImageView.bounds.size.width, iKarteImageView.bounds.size.height); NSLog(@"Frame - width %.6f, height %.6f - Bounds - width %.6f, height %.6f", myImageView.frame.size.width, myView.frame.size.height, myImageView.bounds.size.width, myImageView.bounds.size.height); NSLog(@"Content size width %.6f, height %.6f", myScrollView.contentSize.width, myScrollView.contentSize.height); The NSLog shows the following: Frame - width 1600.000000, height 1819.000000 - Bounds - width 1600.000000, height 1819.000000 Content size width 1600.000000, height 1819.000000 Now comes the miracle, in a subsequent method of the same object I call the same NSLog again. But this time the result is Frame - width 405.000000, height 411.000000 - Bounds - width 1601.510864, height 1625.236938 Content size width 404.617920, height 460.000000 Why is the frame size suddely 405 by 411 pixels? How can the Bounds be 1601 by 1625 where 1625 is roughly 200 pixels less than the original size? When Positioning a further UIImageView at the coordinates of 20 by 1625, the UIImageView is displayed an estimated 200 pixels above the bottom of the content of the UIScrollView. I'm lost ...

    Read the article

  • uiimage oncomplete iphone

    - by dubbeat
    Is there such a thing as an "on load complete" for images in iphone? I want to be able to destroy a UIActivity indicator once and image is loaded. What the general best practice for doing this?

    Read the article

  • Drawing many images inside UIImageView

    - by dusker
    Hi all, i'm looking for a way to draw multiple images (downloaded from a webservice) inside a single uiimageview. So it'd go like i downloaded image #1, and i'd like to draw it inside rect (0,0,100,100) then #2 at (0,100,100,100) etc. I'd like to then be able to take the entire composition and save it as an image in camera roll. thanks in advance for help greetings peter

    Read the article

  • Two Problems I'm having with UIButton and UIView.

    - by Andy
    Hi all, I haven't been programming on the iPhone for very long, but I'm picking it up slowly by googling problems I get. Unfortunately I haven't been able to find an answer for these. I have started a new View-based application in Xcode 3.2.2 and immediately added the following files: myUIView.m and myUIView.h, which are subclasses of UIView. In Interface Builder, I set the subclass of the default UIView to be myUIView. I made a button in the drawRect method. Problem one: The title of the button only appears AFTER I click the screen, why? Problem two: I want the button to produce the modalview - is this possible? The code is as follow: #import "myUIView.h" @implementation myUIView - (void)drawRect:(CGRect)rect { // Drawing code button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(0,0,100,100); [button setTitle:@"butty" forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:button]; } -(void)buttonPressed:(id)sender{ NSLog(@"Button pressed"); //present modal view somehow..? } I can't see how to post attachments, but if anyone thinks it will help I can upload the source. Many thanks, Andy

    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

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