Search Results

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

Page 18/32 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • How can I create a custom UIToolbar like component in a UITableViewController?

    - by Tony
    I have a UITableViewController. I want a "toolbar-ish" component at the bottom. I started by using a background image and a button. In interface builder, I added them to the bottom of the iPhone screen. The problem I ran into was that the background image and button scrolled with the table. I obviously need this fixed at the bottom. Not finding too much direction online, I decided to customize a UIToolbar to look how I want since the position is fixed by default. In my initWithNibName for my UITableViewController, I have: UIImage *shuffleButtonImage = [UIImage imageNamed:@"shuffle_button.png"]; NSArray* toolbarItems = [NSArray arrayWithObjects: [[UIBarButtonItem alloc] initWithImage:shuffleButtonImage style:UIBarButtonItemStylePlain target:self action:@selector(push:)], nil]; [toolbarItems makeObjectsPerformSelector:@selector(release)]; self.toolbarItems = toolbarItems; The problem I am running into now is that the "shuffleButtonImage" is not showing up properly. The shape of the button shows up fine but it is colored white and therefore does not look like the image. Does anyone know why a "white image" would be showing instead of the actual image? Also does it sound like a good idea to customize a UIToolbar or is there a simple way to ensure a fixed position "toolbar-ish" component. To reiterate - my "toolbar-ish" component only needs to be one button at the button of my UITableView. The single button has a gradient color background that I create with an image.

    Read the article

  • iPhone SDK: Rendering a CGLayer into an image object

    - by codemercenary
    Hi all, I am trying to add a curved border around an image downloaded and to be displayed in a UITableViewCell. In the large view (ie one image on the screen) I have the following: productImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:product.image]]; [productImageView setAlpha:0.4]; productImageView.frame = CGRectMake(10.0, 30.0, 128.0, 128.0); CALayer *roundedlayer = [productImageView layer]; [roundedlayer setMasksToBounds:YES]; [roundedlayer setCornerRadius:7.0]; [roundedlayer setBorderWidth:2.0]; [roundedlayer setBorderColor:[[UIColor darkGrayColor] CGColor]]; [self addSubview:productImageView]; In the table view cell, to get it to scroll fast, an image needs to be drawn in the drawRect method of a UIView which is then added to a custom cell. so in drawRect - (void)drawRect:(CGRect)rect { ... point = CGPointMake(boundsX + LEFT_COLUMN_OFFSET, UPPER_ROW_TOP); //CALayer *roundedlayer = [productImageView layer]; //[roundedlayer setMasksToBounds:YES]; //[roundedlayer setCornerRadius:7.0]; //[roundedlayer setBorderWidth:2.0]; //[roundedlayer setBorderColor:[[UIColor darkGrayColor] CGColor]]; //[productImageView drawRect:CGRectMake(boundsX + LEFT_COLUMN_OFFSET, UPPER_ROW_TOP, IMAGE_WIDTH, IMAGE_HEIGHT)]; // [productImageView.image drawInRect:CGRectMake(boundsX + LEFT_COLUMN_OFFSET, UPPER_ROW_TOP, IMAGE_WIDTH, IMAGE_HEIGHT)]; So this works well, but if I remove the comment and try to show the rounded CA layer the scrolling goes really slow. To fix this I suppose I would have to render this image context into a different image object, and store this in an array, then set this image as something like: productImageView.image = (UIImage*)[imageArray objectAtIndex:indexPath.row]; My question is "How do I render this layer into an image?" TIA.

    Read the article

  • iPhone: CoreGraphics and memory management

    - by carloe
    Can someone tell me what I am doing wrong here? I use this method to flip through pages in a PDF. But something in the code seems to not be released properly because every-time I pull a PDF page that contains an image my memory footprint increases. I am fairly new to CoreGraphics, and can't for the life of me figure out where this method would leak memory. -(UIImage *)pageAtIndex:(NSInteger)pageNumber withWidth:(CGFloat)width andHeight:(CGFloat)height { if((pageNumber>0) && (pageNumber<=pageCount)) { CGFloat scaleRatio; // multiplier by which the PDF Page will be scaled UIGraphicsBeginImageContext(CGSizeMake(width, height)); CGContextRef context = UIGraphicsGetCurrentContext(); CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber); CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFBleedBox); //Figure out the orientation of the PDF page and set the scaleRatio accordingly if(pageRect.size.width/pageRect.size.height < 1.0) { scaleRatio = height/pageRect.size.height; } else { scaleRatio = width/pageRect.size.width; } //Calculate the offset to center the image CGFloat xOffset = 0.0; CGFloat yOffset = height; if(pageRect.size.width*scaleRatio<width) { xOffset = (width/2)-(pageRect.size.width*scaleRatio/2); } else { yOffset = height-((height/2)-(pageRect.size.height*scaleRatio/2)); } CGContextTranslateCTM(context, xOffset, yOffset); CGContextScaleCTM(context, 1.0, -1.0); CGContextSaveGState(context); CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFBleedBox, CGRectMake(0, 0, pageRect.size.width, pageRect.size.height), 0, true); pdfTransform = CGAffineTransformScale(pdfTransform, scaleRatio, scaleRatio); CGContextConcatCTM(context, pdfTransform); CGContextDrawPDFPage(context, page); UIImage *tempImage = [UIGraphicsGetImageFromCurrentImageContext() retain]; CGContextRestoreGState(context); UIGraphicsEndPDFContext(); UIGraphicsEndImageContext(); return tempImage; } return nil; }

    Read the article

  • UIViewerTableViewController.m:15: error: expected identifier before '*' token

    - by Aaron Levin
    I am new to objective-c programming. I come from a C# background. I am having problems with the following code I am writing for a proof of concept for an iPhone App: I am getting a number of compile errors but I think they are all due to the first error (could be wrong) - error: expected identifier before '*' token (@synthesize *lists; in the .m file) I'm not sure why my code is showing up the way it is in the view below the editor..hmm any way, any help would be appreciated. .m file // // Created by Aaron Levin on 4/19/10. // Copyright 2010 RonStan. All rights reserved. // import "UIViewerTableViewController.h" @implementation UIViewerTableViewController @synthesize *lists; @synthesize *icon; (void)dealloc { [Lists release]; [super dealloc]; } pragma mark Table View Methods //Customize number of rows in table view (NSInteger)tableView:(UITableView *) tableView numberOfRowsInSection: (NSInteger) section{ return self.Lists.Count; } //Customize the appearence of table view cells (UITableViewCell *) tableView(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath{ static NSString *CellIdentifier = @"Cell"; UITableView *Cell = [tablevView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil){ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [[self.Lists objectAtIndex:indexPath.row] retain]; cell.imageView = self.Icon; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } @end .h file // // UIMyCardsTableViewController.h // MCS ProtoType v0.1 // // Created by Aaron Levin on 4/19/10. // Copyright 2010 RonStan. All rights reserved. // import @interface UIViewerTableViewController : UITableViewController { NSArray *lists; UIImage *icon; } @property (nonatomic,retain) NSArray *lists; @property (nonatomic,retain) UIImage *icon; @end

    Read the article

  • how to generate an event

    - by user262325
    Hello everyone I created a subclass from UIView #import <UIKit/UIKit.h> @interface MeeSelectDropDownView : UIView { UILabel *mainText; UIImage *bgImg; UIImageView *bgView; UIImageView *originView; NSMutableArray *labelArray; int selectedItem; BOOL inSelectTag; float _defaultHeight; } @property (nonatomic , retain) UIImage *bgImg; @property (nonatomic , retain) UIImageView *bgView; @property (nonatomic , retain) NSMutableArray *labelArray; @property (nonatomic , retain) UIImageView *originView; @property (nonatomic , retain) UILabel *mainText; @property (nonatomic , readonly) int selectedItem; - (void) setViewHeight:(float)aheight; -(void) showDropList; -(void) hiddenDropList; -(void) setStringByArray:(NSArray*)array; -(void)hiddenLabels { for(UILabel *aLabel in labelArray){ [aLabel removeFromSuperview]; } } Is it possible to generate an Event from function 'hiddenLabels' to inform and do somethings Thanks interdev

    Read the article

  • How to call PopOver Controller from UITableViewCell.accessoryView?

    - by Vic
    Hi, First I would like to say that I'm really new to ipad/ipod/iphone development, and to objective-c too. With that being said, I'm trying to develop a small application targeting the iPad, using Xcode and IB, basically, I have a table, for each UITableViewCell in the table, I added to the accessoryView a button that contains an image. Here is the code: UIImage *img = [UIImage imageNamed:@"myimage.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; CGRect frame = CGRectMake(0.0, 0.0, img.size.width, img.size.height); button.frame = frame; // match the button's size with the image size [button setBackgroundImage:img forState:UIControlStateNormal]; // set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet [button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; button.backgroundColor = [UIColor clearColor]; cell.accessoryView = button; So far, so good, now the problem is that I want a PopOver control to appear when a user taps the button on the accessoryView of a cell. I tried this on the "accessoryButtonTappedForRowWithIndexPath" of the tableView: UITableViewCell *cell = [myTable cellForRowAtIndexPath:indexPath]; UIButton *button = (UIButton *)cell.accessoryView; //customViewController is the controller of the view that I want to be displayed by the PopOver controller customViewController = [[CustomViewController alloc]init]; popOverController = [[UIPopoverController alloc] initWithContentViewController: customViewController]; popOverController.popoverContentSize = CGSizeMake(147, 122); CGRect rect = button.frame; [popOverController presentPopoverFromRect:rect inView:cell.accessoryView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; The problem with this code is that it shows the Popover at the top of the application View, while debugging I saw the values of "rect" and they are: x = 267 y = 13 so I think it is pretty obvious why the PopOver is being displayed so up on the view, so my question is, how can I get the correct values for the PopOver to appear just below the button on the accessoryView of the cell? Also, as you can see, I'm telling it to use the "cell.accessoryView" for the "inView:" attribute, is that okay?

    Read the article

  • iPhone: CATiledLayer/UIScrollView wont scroll after zooming and only zooms to anchor point

    - by Brodie4598
    Here is the problem... I am using CA Tiled Layer to display a large jpg. The view loads okay, and when I go to scroll around, it works fine. However, as soon as I zoom in or out once, it scrolls to the top left (to the anchor point) and will not scroll at all. The zooming works fine, but I just cannot scroll. Here is my code: #import <QuartzCore/QuartzCore.h> #import "PracticeViewController.h" @implementation practiceViewController //@synthesize image; - (void)viewDidLoad { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect pageRect = CGRectMake(0, 0, image.size.width, image.size.height); CATiledLayer *tiledLayer = [CATiledLayer layer]; tiledLayer.anchorPoint = CGPointMake(0.0f, 1.0f); tiledLayer.delegate = self; tiledLayer.tileSize = CGSizeMake(1000, 1000); tiledLayer.levelsOfDetail = 6; tiledLayer.levelsOfDetailBias = 0; tiledLayer.bounds = pageRect; tiledLayer.transform = CATransform3DMakeScale(1.0f, -1.0f, 0.3f); myContentView = [[UIView alloc] initWithFrame:self.view.bounds]; [myContentView.layer addSublayer:tiledLayer]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; scrollView.delegate = self; scrollView.contentSize = pageRect.size; scrollView.minimumZoomScale = .2; scrollView.maximumZoomScale = 1; [scrollView addSubview:myContentView]; [self.view addSubview:scrollView]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return myContentView; } - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect imageRect = CGRectMake (0.0, 0.0, image.size.width, image.size.height); CGContextDrawImage (ctx, imageRect, [image CGImage]); } @end

    Read the article

  • Odd background image resizing on animating UIView

    - by Woody
    I have a UIView in the middle of a view that I am using as a game playing area (in a 2d cocoa view). This image has a background image of the same size as the view. Resizing the view I use animation to make it look smooth (and that works fine). However, when the animation starts, the background image immediately changes size, tiling or being clipped to a size that when the animation finishes, the background image is physically the same size. I don't want this, I want the image to always fit the view, regardless of the view size. UIImage *bgImage = [UIImage imageNamed:@"head.png"]; ... // resize the image returning another image self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:resizedImage]; [UIView beginAnimations:@"resizeView" context:nil]; [UIView setAnimationDuration:.5]; int localViewSize = ... // work out view sizes self.view.frame = CGRectMake(... ,localViewSize,localViewSize); [UIView commitAnimations]; It looks very odd as it jumps to a different size, then animates to the original size. I am guessing that maybe I would have to make a separate view underneath my main view but is that the only way?

    Read the article

  • UITableViewCell Custom accessory - get the row of accessory

    - by Emil
    Hi. I have a pretty big issue. I am trying to create a favorite-button on every UITableViewCell in a UITableView. That works very good, and I currently have an action and selector performed when pressed. accessory = [UIButton buttonWithType:UIButtonTypeCustom]; [accessory setImage:[UIImage imageNamed:@"star.png"] forState:UIControlStateNormal]; accessory.frame = CGRectMake(0, 0, 15, 15); accessory.userInteractionEnabled = YES; [accessory addTarget:self action:@selector(didTapStar) forControlEvents:UIControlEventTouchUpInside]; cell.accessoryView = accessory; And selector: - (void) didTapStar { UITableViewCell *newCell = [tableView cellForRowAtIndexPath:???]; accessory = [UIButton buttonWithType:UIButtonTypeCustom]; [accessory setImage:[UIImage imageNamed:@"stared.png"] forState:UIControlStateNormal]; accessory.frame = CGRectMake(0, 0, 26, 26); accessory.userInteractionEnabled = YES; [accessory addTarget:self action:@selector(didTapStar) forControlEvents:UIControlEventTouchDown]; newCell.accessoryView = accessory; } Now, here's the problem: I want to know what row the accessory that was pressed belongs to. How can I do this? Thank you :)

    Read the article

  • Why is my addSubview: method causing a leak?

    - by Nathan
    Okay, so I have done a ton of research on this and have been pulling my hair out for days trying to figure out why the following code leaks: [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; UIImage *comicImage = [self getCachedImage:[NSString stringWithFormat:@"%@%@%@",@"http://url/",comicNumber,@".png"]]; self.imageView = [[[UIImageView alloc] initWithImage:comicImage] autorelease]; [self.scrollView addSubview:self.imageView]; self.scrollView.contentSize = self.imageView.frame.size; self.imageWidth = [NSString stringWithFormat:@"%f",imageView.frame.size.width]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; Both self.imageView and self.scrollView are @propety (nonatomic, retain) and released in my dealloc.. imageView isn't used anywhere else in the code. This code is also run in a thread off of the main thread. If I run this code on my device, it will quickly run out of memory if I continually load this view. However, I've found if I comment out the following line: [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; UIImage *comicImage = [self getCachedImage:[NSString stringWithFormat:@"%@%@%@",@"http://url/",comicNumber,@".png"]]; self.imageView = [[[UIImageView alloc] initWithImage:comicImage] autorelease]; //[self.scrollView addSubview:self.imageView]; self.scrollView.contentSize = self.imageView.frame.size; self.imageWidth = [NSString stringWithFormat:@"%f",imageView.frame.size.width]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; Memory usage becomes stable, no matter how many times I load the view. I have gone over everything I can think to see why this is leaking, but as far as I can tell I have all my releases straight. Can anyone see what I am missing?

    Read the article

  • Help with iphone button pressed

    - by StealthRT
    I am trying to see which button was clicked on so I can preform the correct logic. This is the code for the buttons: UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(270, 423, 60, 60)]; [button addTarget:self action:@selector(buttonPressedAction:) forControlEvents:UIControlEventTouchUpInside]; [button setBackgroundImage:[[UIImage imageNamed:@"refreshicon.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal]; UIButton *button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 423, 60, 60)]; [button2 addTarget:self action:@selector(buttonPressedAction:) forControlEvents:UIControlEventTouchUpInside]; [button2 setBackgroundImage:[[UIImage imageNamed:@"login.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal]; [self.navigationController.view addSubview:button]; [self.navigationController.view addSubview:button2]; And this is how I call the buttonPressedAction: - (void)buttonPressedAction:(id)sender { NSLog(@"%@", [sender value]); isRefreshing = TRUE; [self loadTheXML]; [self.tableView reloadData]; } But when I use NSLog to see what the sender value is, it crashes. Any advice for what's happening and how to correct it?

    Read the article

  • Custom UIButton for Iphone.

    - by Amal
    I have an view in my App which has a number of buttons based on the number of items returned by the server. So if the server returns say 10 items, there should be 10 buttons and clicking on each button should call a different person. For the above purpose I created a custom button class deriving from UIButton. @implementation HopitalButton @synthesize index; @synthesize button_type; - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { UIImage* img = [UIImage imageNamed:@"dr_btn.png"]; [img stretchableImageWithLeftCapWidth:10 topCapHeight:10]; [self setBackgroundImage:img forState:UIControlStateNormal]; [self setTitleColor:[UIColor colorWithRed:0.698 green:0.118 blue:0.376 alpha:1] forState:UIControlStateNormal] ; [self setFont:[UIFont fontWithName:@"Helvetica Bold" size:13]]; self.titleLabel.textColor = [UIColor colorWithRed:178 green:48 blue:95 alpha:1]; self.adjustsImageWhenHighlighted = YES; } return self; } - (void)dealloc { [super dealloc]; } @end Now the problem with the above code is that it does not create buttons that look similar to the buttons created by default in Interface builder. The borders are missing. And I create buttons of the above type by the following code: HopitalButton* hb = [[HopitalButton alloc] init]; hb.button_type = @"call"; hb.frame = CGRectMake(50, 50 + i * 67, 220, 40); [self.scroll_view addSubview:hb]; [hb setTitle:[[[self.office_full_list objectAtIndex:i] objectForKey:@"Staff" ]objectForKey:@"FullName"] forState:UIControlStateNormal]; hb.index = [NSNumber numberWithInt:[self.button_items count]]; [self.button_items insertObject:hb atIndex:[self.button_items count]]; [hb addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; I am not finding a way to set the button type for this custom button. Is there a way i can do it ? Or is there a better way to design the code.

    Read the article

  • add button to navigationbar programatically

    - by mac
    Hi i need to set the button on right side, in navigation bar, programatically , so that if i press the button i will perform some actions, i have created the navigation bar,programatically by navBar=[[UINavigationBar alloc]initWithFrame:CGRectMake(0,0,320,44) ]; similarly i need to add the button , right side of this navigation bar,for that i used, 1) UIView* container = [[UIView alloc] init]; // create a button and add it to the container UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 130, 44.01)]; [container addSubview:button]; [button release]; // add another button button = [[UIButton alloc] initWithFrame:CGRectMake(160, 0, 50, 44.01)]; [container addSubview:button]; [button release]; // now create a Bar button item UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithCustomView:container]; // set the nav bar's right button item self.navigationItem.rightBarButtonItem = item; [item release]; 2) UIImage *im; im=[UIImage imageNamed:@"back.png"]; [button setImage:im forState:UIControlStateNormal]; [im release]; backButton = [[UIBarButtonItem alloc] initWithCustomView:button]; [backButton setImageInsets:UIEdgeInsetsMake(0, -10,5, 5)]; [self.navigationItem setRightBarButtonItem:backButton]; 3) UIBarButtonItem *refreshItem = [[UIBarButtonItem alloc] initWithTitle:@"button" style:UIBarButtonItemStylePlain target:self action:@selector(refreshLogsAction:)]; self.navigationItem.rightBarButtonItem = refreshItem; [refreshItem release]; i tried all these type of codings , no use, these codes are not displaying the button at rigth side,please help me. thanks in advance,

    Read the article

  • CAScrollLayer doesn't scroll!

    - by Cliff
    Maybe it's because it's late. Whatever the reason I can't figure out why I'm having trouble with a simple CSScrollLayer example I'm trying. I add a 50 pixel Eclipse icon to a view based project and in my initialize method (called from initWithNibName:bundle:) I have this: -(void) initialize { CAScrollLayer *scrollLayer = [CAScrollLayer layer]; scrollLayer.backgroundColor = [[UIColor blackColor] CGColor]; CGRect bounds = self.view.bounds; scrollLayer.bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height); scrollLayer.contentsRect = CGRectMake(0, 0, bounds.size.width + 800, bounds.size.height + 800); scrollLayer.borderWidth = 2.5; scrollLayer.borderColor = [[UIColor redColor] CGColor]; scrollLayer.position = CGPointMake(self.view.center.x, self.view.center.y - 20); scrollLayer.scrollMode = kCAScrollBoth; [self.view.layer addSublayer:scrollLayer]; UIImage *image = [UIImage imageNamed:@"eclipse32.gif"]; for(int i=0; i<6; i++) { layer = [CALayer layer]; layer.backgroundColor = [[UIColor blackColor] CGColor]; layer.bounds = CGRectMake(0, 0, 100, 100); layer.contents = (id)[image CGImage]; layer.position = CGPointMake(layer.bounds.size.width * i, self.view.center.y); [scrollLayer addSublayer:layer]; } // [button removeFromSuperview]; // [self.view addSubview:button]; // self.view.userInteractionEnabled = YES; [image release]; } The scroll layer shows, the icon is repeated on the layer I have a border around the edge of the screen. Everything is lovely except I can't scroll the icons. I've tried with/without setting scroll mode. I've tried with a single stretched icon that falls off screen. I've tried everything. What am I doing wrong?

    Read the article

  • Saving data - does work on Simulator, not on Device

    - by Peter Hajas
    I use NSData to persist an image in my application. I save the image like so (in my App Delegate): - (void)applicationWillTerminate:(UIApplication *)application { NSLog(@"Saving data"); NSData *data = UIImagePNGRepresentation([[viewController.myViewController myImage]image]); //Write the file out! NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path_to_file = [documentsDirectory stringByAppendingString:@"lastimage.png"]; [data writeToFile:path_to_file atomically:YES]; NSLog(@"Data saved."); } and then I load it back like so (in my view controller, under viewDidLoad): NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path_to_file = [documentsDirectory stringByAppendingString:@"lastimage.png"]; if([[NSFileManager defaultManager] fileExistsAtPath:path_to_file]) { NSLog(@"Found saved file, loading in image"); NSData *data = [NSData dataWithContentsOfFile:path_to_file]; UIImage *temp = [[UIImage alloc] initWithData:data]; myViewController.myImage.image = temp; NSLog(@"Finished loading in image"); } This code works every time on the simulator, but on the device, it can never seem to load back in the image. I'm pretty sure that it saves out, but I have no view of the filesystem. Am I doing something weird? Does the simulator have a different way to access its directories than the device? Thanks!

    Read the article

  • is there a way to show Uitableviewcell selection on limited frame?

    - by Rahul Vyas
    i have a uitableview cell added some labels something like this - (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] autorelease]; UIImage* myImage = [UIImage imageNamed:@"AccessoryForDealsMain.png"]; UIImageView *MyimageView = [[UIImageView alloc] initWithImage:myImage]; MyimageView.contentMode=UIViewContentModeScaleToFill; cell.accessoryView=MyimageView; [MyimageView release]; UILabel *BluePatti = [[UILabel alloc] init]; BluePatti.frame=CGRectMake(0,0,4,44); BluePatti.backgroundColor = BLUEPATTI;//[UIColor blueColor]; UILabel *BlackLine = [[UILabel alloc] init]; BlackLine.frame=CGRectMake(3,0,1, 45); BlackLine.backgroundColor = BLACK_LINE; [BluePatti addSubview:BlackLine]; [BlackLine release]; [cell.contentView addSubview:BluePatti]; [BluePatti release]; UILabel *Seperator = [[UILabel alloc] initWithFrame:CGRectZero]; Seperator.backgroundColor = [UIColor colorWithRed:234/256.0 green:234/256.0 blue:234/256.0 alpha:1.0]; //[UIColor lightGrayColor]; Seperator.frame = CGRectMake(4,43,316,1); [cell.contentView addSubview:Seperator]; [Seperator release]; } if(indexPath.section==5) { cell.textLabel.text=[self.GenderCellData objectAtIndex:indexPath.row]; cell.textLabel.textColor=CELL_TEXT_COLOR; cell.textLabel.font=CELL_FONT; } else { cell.textLabel.text=@"Cells"; cell.textLabel.font=CELL_FONT; } return cell; } now when i touch cell it shows blue selection above all subviews.How do i change selection frame and colour?

    Read the article

  • iPhone - UIViewController not rotating when device orientation changes

    - by Ryu
    I have got my own custom UIViewController, which contains a UIScrollView with an UIImageView as it's subview. I would like to make the image to auto rotate when device orientation changes, but it doesn't seem to be working... In the header file, I've got; @interface MyViewController : UIViewController <UIScrollViewDelegate> { IBOutlet UIScrollView *containerView; UIImageView *imageView; } These components are initialised in the loadView function as below; containerView = [[UIScrollView alloc] initWithFrame:frame]; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://..."]]; UIImage *image = [[UIImage alloc] initWithData:data]; imageView = [[UIImageView alloc] initWithImage:image]; [image release]; [containerView addSubview:imageView]; And I have added the following method, assuming that's all I need to make the view auto-rotate... -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } MyViewController loads fine with the image I've specified to grab from the URL, and the shouldAutorotate... function is being called, with the correct UIInterfaceOrientation, when I flip the device too. However, didRotateFromInterfaceOrientation method do not get called, and the image doesn't seem to rotate itself... Could someone please point out what I need to add, or what I have done wrong here? Thanks in advance!

    Read the article

  • pass objective c object and primitive type into a void *

    - by user674669
    I want to pass 2 variables: UIImage * img int i into another method that only takes a (void *) I tried making a C struct containing both img and i struct MyStruct { UIImage *img; int i; } but xcode gives me an error saying "ARC forbids Objective-C objects in structs or unions" The next thing I tried is to write an objective-c class MyStruct2 containing img and i, alloc-initing an instance of it and typecasting it as (__bridge void*) before passing it to the method. Seems little involved for my use case. Seems like there should be a better way. What's the simplest way to achieve this? Thank you. Edit based on comments: I have to use void * as it is required by the UIView API. I created a selector as mentioned by UIVIew API + (void)setAnimationDidStopSelector:(SEL)selector Please see documentation for setAnimationDidStopSelector at http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html . It says ... The selector should be of the form: - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context I want to pass both img and i into the (void *)context argument.

    Read the article

  • Static variable for communication among like-typed objects

    - by Dan Ray
    I have a method that asynchronously downloads images. If the images are related to an array of objects (a common use-case in the app I'm building), I want to cache them. The idea is, I pass in an index number (based on the indexPath.row of the table I'm making by way through), and I stash the image in a static NSMutableArray, keyed on the row of the table I'm dealing with. Thusly: @implementation ImageDownloader ... @synthesize cacheIndex; static NSMutableArray *imageCache; -(void)startDownloadWithImageView:(UIImageView *)imageView andImageURL:(NSURL *)url withCacheIndex:(NSInteger)index { self.theImageView = imageView; self.cacheIndex = index; NSLog(@"Called to download %@ for imageview %@", url, self.theImageView); if ([imageCache objectAtIndex:index]) { NSLog(@"We have this image cached--using that instead"); self.theImageView.image = [imageCache objectAtIndex:index]; return; } self.activeDownload = [NSMutableData data]; NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:url] delegate:self]; self.imageConnection = conn; [conn release]; } //build up the incoming data in self.activeDownload with calls to didReceiveData... - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"Finished downloading."); UIImage *image = [[UIImage alloc] initWithData:self.activeDownload]; self.theImageView.image = image; NSLog(@"Caching %@ for %d", self.theImageView.image, self.cacheIndex); [imageCache insertObject:image atIndex:self.cacheIndex]; NSLog(@"Cache now has %d items", [imageCache count]); [image release]; } My index is getting through okay, I can see that by my NSLog output. But even after my insertObject: atIndex: call, [imageCache count] never leaves zero. This is my first foray into static variables, so I presume I'm doing something wrong. (The above code is heavily pruned to show only the main thing of what's going on, so bear that in mind as you look at it.)

    Read the article

  • ScrollView content async downloading problem

    - by Newbee
    Hi! I have UIScrollView with lots of UIImageView inside. In the loadView method I assign some temporary image for each of subview UIImageView images and starts several threads to async download images from internet. Each thread downloads and assign images as follows: NSData *data = [NSData dataWithContentsOfURL:URL]; UIImage *img = [UIImage imageWithData:data]; img_view.image = img; Here is the problem - I expects picture will changed after each image downloaded by I can see only temporary images until all images will downloads. UIScrollView still interact while images downloads - I can scroll temporary images inside it and see scrollers and nothing blocks run loop, but downloaded images doesn't updates.. What I tried to do: Call sleep() in the download thread -- not helps. Call setNeedsDisplay for each ImageView inside ScrollView and for ScrollView -- not helps. What's wrong ? Thanks. Update. I tried some experiments with number of threads and number of images to download. Now I'm sure -- images redraws only when thread finished. For example - if I load 100 images with one thread -- picture updates one time after all images downloads. If I increase number of threads to 10 -- picture updates 10 times -- 10 images appears per update. One more update. I fixed problem by staring new thread from the downloading threads each time one image downloaded and exit current thread (instead of download several images in one thread in the cycle and exit thread only when all downloaded). Obviously it's not a good solution and there must be right approach.

    Read the article

  • how to initialize and implement the matrix inside the function in objective-C?

    - by Rajendra Bhole
    Hi, I want to develop an application in which i want to be initialize the matrix for manipulation. The code as follows, struct pixel { Byte r, g, b,a; int count; }; (NSInteger) processImage1: (UIImage*) image { 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; while (numberOfPixels &gt; 0) { if (pixels->r == 254 || pixels->g == 77 || pixels->b==254) { numberOfRedPixels++; } pixels++; numberOfPixels--; } CGContextRelease(context); } free(pixels); } return 1; } I want to implement the matrix inside the function of - (NSInteger) processImage1: (UIImage*) image {} The matrix should have be row = image.size.width and column = image.size.height.

    Read the article

  • Why won't my CATiledLayer scroll in a UIScrollView after zooming?

    - by Brodie4598
    I'm currently having the following problem with CATiledLayer: when the view first loads, the scrolling works perfectly, but then when you zoom once, the view snaps to the anchor point (top left corner) and it can no longer scroll at all. The zooming works in that it will zoom in and out, but it will only zoom to the top left corner. My code is as follows: #import <QuartzCore/QuartzCore.h> #import "PracticeViewController.h" @implementation practiceViewController //@synthesize image; - (void)viewDidLoad { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect pageRect = CGRectMake(0, 0, image.size.width, image.size.height); CATiledLayer *tiledLayer = [CATiledLayer layer]; tiledLayer.anchorPoint = CGPointMake(0.0f, 1.0f); tiledLayer.delegate = self; tiledLayer.tileSize = CGSizeMake(1000, 1000); tiledLayer.levelsOfDetail = 6; tiledLayer.levelsOfDetailBias = 0; tiledLayer.bounds = pageRect; tiledLayer.transform = CATransform3DMakeScale(1.0f, -1.0f, 0.3f); myContentView = [[UIView alloc] initWithFrame:self.view.bounds]; [myContentView.layer addSublayer:tiledLayer]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; scrollView.delegate = self; scrollView.contentSize = pageRect.size; scrollView.minimumZoomScale = .2; scrollView.maximumZoomScale = 1; [scrollView addSubview:myContentView]; [self.view addSubview:scrollView]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return myContentView; } - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect imageRect = CGRectMake (0.0, 0.0, image.size.width, image.size.height); CGContextDrawImage (ctx, imageRect, [image CGImage]); } @end

    Read the article

  • Memory leak when returning object

    - by Yakattak
    I have this memory leak that has been very stubborn for the past week or so. I have a class method I use in a class called "ArchiveManager" that will unarchive a specific .dat file for me, and return an array with it's contents. Here is the method: +(NSMutableArray *)unarchiveCustomObject { NSMutableArray *array = [NSMutableArray arrayWithArray:[NSKeyedUnarchiver unarchiveObjectWithFile:/* Archive Path */]]; return array; } I understand I don't have ownership of it at this point, and I return it. CustomObject *myObject = [[ArchiveManager unarchiveCustomObject] objectAtIndex:0]; Then, later when I unarchive it in a view controller to be used (I don't even create an array of it, nor do I make a pointer to it, I just reference it to get something out of the array returned by unarchiveCustomIbject (objectAtIndex). This is where Instruments is calling a memory leak, yet I don't see how this can leak! Any ideas? Thanks in advance. Edit: CustomObject initWithCoder added: -(id)initWithCoder:(NSCoder *)aDecoder { if (self = [super init]) { self.string1 = [aDecoder decodeObjectForKey:kString1]; self.string2 = [aDecoder decodeObjectForKey:kString2]; self.string3 = [aDecoder decodeObjectForKey:kString3]; UIImage *picture = [[UIImage alloc] initWithData:[aDecoder decodeObjectForKey:kPicture]]; self.picture = picture; self.array = [aDecoder decodeObjectForKey:kArray]; [picture release]; } return self; }

    Read the article

  • OpenCV and iPhone

    - by gn-mithun
    Hello, I am writing an application to create a movie file from a bunch of images on an iPhone. I am using OpenCv. I downloaded openCv static libraries for arm(iPhones native instruction architecture) and the libraries were generated just fine. There were no problems linking to them libraries. As a first step, i was trying to create a .avi file using one image, to see if it works. But cvCreateVideoWriter always returns me a NULL value. I did some searchin and i believe its due to the codec not being present. I am trying this on the iPhone simulator. this is what i do... (void)viewDidLoad { [super viewDidLoad]; UIImage *anImage = [UIImage imageNamed:@"1.jpg"]; IplImage *img_color = [self CreateIplImageFromUIImage:anImage]; //The image gets created just fine CvVideoWriter *writer = cvCreateVideoWriter("out.avi",CV_FOURCC('P','I','M','1'), 25,cvSize(320,480),1); //writer is always null int result = cvWriteFrame(writer, img_color); NSLog(@"\n%d",result); //hence this is also 0 all the time cvReleaseVideoWriter(&writer); } I am not sure about the the second parameter. What sort of codec or what exactly it does... I am a n00B in this. Any suggestions?

    Read the article

  • iPhone and OpenCV

    - by gn-mithun
    Hello, I am writing an application to create a movie file from a bunch of images on an iPhone. I am using OpenCv. I downloaded openCv static libraries for arm(iPhones native instruction architecture) and the libraries were generated just fine. There were no problems linking to them libraries. As a first step, i was trying to create a .avi file using one image, to see if it works. But cvCreateVideoWriter always returns me a NULL value. I did some searchin and i believe its due to the codec not being present. I am trying this on the iPhone simulator. this is what i do... (void)viewDidLoad { [super viewDidLoad]; UIImage *anImage = [UIImage imageNamed:@"1.jpg"]; IplImage *img_color = [self CreateIplImageFromUIImage:anImage]; //The image gets created just fine CvVideoWriter *writer = cvCreateVideoWriter("out.avi",CV_FOURCC('P','I','M','1'), 25,cvSize(320,480),1); //writer is always null int result = cvWriteFrame(writer, img_color); NSLog(@"\n%d",result); //hence this is also 0 all the time cvReleaseVideoWriter(&writer); } I am not sure about the the second parameter. What sort of codec or what exactly it does... I am a n00B in this. Any suggestions?

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >