Search Results

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

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

  • setBackButtonBackgroundImage without title IOS5

    - by user1736571
    I'm trying to get a back button without a title but I can't make it work. I am really new in objective-c... UIImage *backButtonImage = [[UIImage imageNamed:@"back.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 30, 50)]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; With that code I have my back button but also the title of the previous page. I found some working examples using the class UIViewController but in my case the code is in the appDelegate.m file. Any idea how I can make it work ?

    Read the article

  • A question related to UIButton

    - by vikas Savardekar
    I have taken customview in my code for UIButton. UIButton *button= [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; //(UIButton *)newCell.accessoryView; [button addTarget:self action:@selector(checkedimage:) forControlEvents:UIControlEventTouchUpInside]; -(IBAction)checkedimage:(id)sender { NSLog(@"checkedimage"); if(checkImage == NO) { newImage = [UIImage imageNamed:@"a.png"]; checkImage=YES; } else if(checkImage==YES) { newImage = [UIImage imageNamed:@"b.png"]; checkImage=NO; } } but when i click on UIButton it is not going to action checkedimage why?

    Read the article

  • Objective - C, fastest way to show sequence of images in UIImageView

    - by Almas Adilbek
    I have hundreds of images, which are frame images of one animation (24 images per second). Each image size is 1024x690. My problem is, I need to make smooth animation iterating each image frame in UIImageView. I know I can use animationImages of UIImageView. But it crashes, because of memory problem. Also, I can use imageView.image = [UIImage imageNamed:@""] that would cache each image, so that the next repeat animation will be smooth. But, caching a lot of images crashed app. Now I use imageView.image = [UIImage imageWithContentsOfFile:@""], which does not crash app, but doesn't make animation so smooth. Maybe there is a better way to make good animation of frame images? Maybe I need to make some preparations, in order to somehow achieve better result. I need your advices. Thank you!

    Read the article

  • How can I make a UIButton "flash" (with a glow, or changing it's image for a split second)

    - by marty
    I tried just making the image switch to black and then use sleep(1) and have it go back to the original image, but the sleep doesn't work at the right time, and I can't even see the black flash it goes so fast. [blueButton setImage:[UIImage imageNamed:@"black.png"] forState:UIControlStateNormal]; sleep(3); [blueButton setImage:[UIImage imageNamed:@"blue.png"] forState:UIControlStateNormal]; I just want to make it give a indicator to this button. Any thoughts? Thanks.

    Read the article

  • How can I make a UIButton "flash" (with a glow, or changing its image for a split second)

    - by marty
    I tried just making the image switch to black and then use sleep(1) and have it go back to the original image, but the sleep doesn't work at the right time, and I can't even see the black flash it goes so fast. [blueButton setImage:[UIImage imageNamed:@"black.png"] forState:UIControlStateNormal]; sleep(3); [blueButton setImage:[UIImage imageNamed:@"blue.png"] forState:UIControlStateNormal]; I just want to make it give a indicator to this button. Any thoughts? Thanks.

    Read the article

  • how to delete a image from iphone application

    - by pankaj
    I am working an iphone app where i am giving the option of downloading an image to user's iphone. Following is my code for downloading of image. UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlAddress]]]; NSString *pngFilePath = [[[NSString stringWithFormat:@"%@/",docDir] stringByAppendingString:[NSString stringWithFormat:@"%@",couponID]] stringByAppendingString:@".png"]; NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)]; [data1 writeToFile:pngFilePath atomically:YES]; My above code works fine but now i want to give option of deleting the image downloaded from above code. Can some one please advice me how can i delete a image file from iphone.

    Read the article

  • Get image from website url iphone faster

    - by dragon
    Hi i want to get image faster from website in iphone.. Now i get image from website url using this function NSData *data; UIImage *Favimage; data = [NSData dataWithContentsOfURL:[NSURL URLWithString:WebsiteUrl]]; Favimage = [[UIImage alloc]initWithData:data]; But it takes some time to get image from website url. Now i want get faster image means ? What can i do ? Is there any api in apple iphone sdk? Can any one help me ? Thanks in advance.....

    Read the article

  • Writing photos (and other things) to disk and getting them later in iphone

    - by ebabchick
    I'm trying to write an image to disk: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSString* savePath = [documentsPath stringByAppendingPathComponent:@"photo"]; BOOL result = [data writeToFile:savePath atomically:YES]; if(result) NSLog(@"Save of photo success!"); Then, later, I try to retrieve for a table view cell image: NSData* getPhoto = [NSData dataWithContentsOfFile:[leaf content]]; UIImage* myImage = [UIImage imageWithData:getPhoto]; cell.imageView.image = myImage; Yes, I checked to make sure the [leaf content] returns the same NSString as savePath. What else could be the problem? [NSData dataWithContentsOfFile:[leaf content]]; returns nil.... Thanks guys

    Read the article

  • iphone best practice, how to load multiple high quality images

    - by bennythemink
    Hi guys and girls, I have about 20-ish high quality images (~3840x5800 px) that I need to load in a simple gallery type app. The user clicks a button and the next image is loaded into the UIImageView. I currently use [UIImage imageWithContentsOfFile:] which takes about 6 seconds to load each image in the simulator :( if I use [UIImage imageNamed:] it takes even longer to load but caches the images which means its quicker if the user wishes to see the same images again. But it may cause memory problems later with all that caching crashing my app. I want to know whats the best practice for loading these? I'm experimenting with reducing image file size as much as is possible but I really need them to be high quality image for the purpose of the app (zoomable, etc.). Thanks for any advice

    Read the article

  • MKPinAnnotationView - hard to drag

    - by James Zaghini
    I have a MKPinAnnotationView that the user can drag around the map. It is very difficult for a user to drag the pin. I've tried increasing the frame size and also using a giant custom image. But nothing seems to actually change the hit area for the drag to be larger than default. Consequently, I have to attempt to tap/drag about ten times before anything happens. MKPinAnnotationView *annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"bluedot"] autorelease]; UIImage *image = [UIImage imageNamed:@"blue_dot.png"]; annView.image = image; annView.draggable = YES; annView.selected = YES; return annView; What am I missing here?

    Read the article

  • How to load image from NSMutableArray

    - by pbcoder
    I want to load the image URL from my NSMutableArray. Here is my Code: id path = (NSString *)[[stories objectAtIndex: storyIndex] objectForKey: @"icon"]; NSURL *url = [NSURL URLWithString:path]; NSData *data = [NSData dataWithContentsOfURL:url]; UIImage *img = [[UIImage alloc] initWithData:data cache:NO]; If I use: id path = @"http://www.xzy.de/icon.png"; it´s all right, but not if I want to extract the imageURL from my Array Anyone who can help me? Thanks!

    Read the article

  • Problem in to navigate on UITableView on the UIButtonClick which is present in UITabBarController sc

    - by Rajendra Bhole
    Hi, I develop an application in which i want to on UIButton Click the application navigate on UITableViewcontroller class.The UIButton is already on UITabBarController during the navigation the tab bar should be visible.The calling method in first tab bar controller class is, [appDelegate.nvcHome pushViewController:itemMenuTable animated:YES]; [itemMenuTable release]; itemMenuTable = nil; But it given me the following problem in GDB, Application tried to push a nil view controller on target . Also i want to display the icon and title of UITabBarController in programmatically, the code is, homeViewControllerLink = [[homeViewController alloc]initWithNibName:@"homeViewController" bundle:nil]; nvcHome = [[UINavigationController alloc]initWithRootViewController:homeViewControllerLink]; nvcHome.navigationBar.barStyle = UIStatusBarStyleBlackOpaque; UIImage *imgHomeTab = [UIImage imageNamed:@"home"]; [nvcHome.tabBarItem initWithTitle:@"Home" image:imgHomeTab tag:101]; [homeViewControllerLink release]; But it does not display when i running my app on iphone simulator.

    Read the article

  • How to draw multiple line text to uiimageview iphone?

    - by Hu?nh Phong
    I have UITextView for text, after user press DONE, I convert text to UIImageView and show it. It works with one line of text very good, and Screenshot 1 . But if user types two lines, or more: the result is still one line??? Screenshot 2 I want to display two or more lines in UIimageView Can anybody help me! Thank you very much! Here is my code: -(UIImage *)convertTextToImage : (ObjectText *) objT; { UIGraphicsBeginImageContext(CGSizeMake(([objT.content sizeWithFont:objT.font].width+10), ([objT.content sizeWithFont:objT.font].height+10))); [[objT getcolor] set]; [objT.content drawAtPoint:CGPointMake(5, 5) withFont:objT.font]; UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return result; }

    Read the article

  • Rendering Texture Quad to Screen or FBO (OpenGL ES)

    - by Usman.3D
    I need to render the texture on the iOS device's screen or a render-to-texture frame buffer object. But it does not show any texture. It's all black. (I am loading texture with image myself for testing purpose) //Load texture data UIImage *image=[UIImage imageNamed:@"textureImage.png"]; GLuint width = FRAME_WIDTH; GLuint height = FRAME_HEIGHT; //Create context void *imageData = malloc(height * width * 4); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(imageData, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); //Prepare image CGContextClearRect(context, CGRectMake(0, 0, width, height)); CGContextDrawImage(context, CGRectMake(0, 0, width, height), image.CGImage); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); Simple Texture Quad drawing code mentioned here //Bind Texture, Bind render-to-texture FBO and then draw the quad const float quadPositions[] = { 1.0, 1.0, 0.0, -1.0, 1.0, 0.0, -1.0, -1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0 }; const float quadTexcoords[] = { 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0 }; // stop using VBO glBindBuffer(GL_ARRAY_BUFFER, 0); // setup buffer offsets glVertexAttribPointer(ATTRIB_VERTEX, 3, GL_FLOAT, GL_FALSE, 3*sizeof(float), quadPositions); glVertexAttribPointer(ATTRIB_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, 2*sizeof(float), quadTexcoords); // ensure the proper arrays are enabled glEnableVertexAttribArray(ATTRIB_VERTEX); glEnableVertexAttribArray(ATTRIB_TEXCOORD0); //Bind Texture and render-to-texture FBO. glBindTexture(GL_TEXTURE_2D, GLid); //Actually wanted to render it to render-to-texture FBO, but now testing directly on default FBO. //glBindFramebuffer(GL_FRAMEBUFFER, textureFBO[pixelBuffernum]); // draw glDrawArrays(GL_TRIANGLES, 0, 2*3); What am I doing wrong in this code? P.S. I'm not familiar with shaders yet, so it is difficult for me to make use of them right now.

    Read the article

  • How can I successfully dechiper Instruments Messages for iPhone Leak

    - by dubbeat
    Hi, I have a memory leak in my app. (This is the first of many I'm sure :() I've being trying to use Instruments to find it. Instruments gives me a lot of information but I think I must just not know how to use this information. What I did so far was 1) Run the app with Instruments 2) Memory Leak Occurs named general -stack 16 3) Find general - stack 16 in the object allocations part of instruments 4) The information here says the event type is a malloc, that webcore is responsible and the something named WKSetCurrentGraphicContext is the responsible caller. How can I use this given information to discover where in my code the leak is being caused? If I comment out the following function I don't get the leak warning so I guess it should be in there somewhere but I can't see where -(void)constructFeatured { NSString *imageName =[[NSString alloc] initWithFormat:@"%@%@%@",@"http://myweb/avatar_", featuredValueObject.featured_promo_artistid, @".jpg"]; NSURL *url = [NSURL URLWithString:imageName]; CGRect frame; frame.size.width=100; frame.size.height=100; frame.origin.x=20; frame.origin.y=39; [imageName release]; imageName=nil; SDWebImageManager *manager = [SDWebImageManager sharedManager]; UIImage *cachedImage = [manager imageWithURL:url]; if (cachedImage) { cachedImage =[ImageManipulator makeRoundCornerImage:cachedImage : 10 : 10]; UIImageView *avatarimageview = [[UIImageView alloc]initWithImage:cachedImage ]; avatarimageview.frame=frame; [self.view addSubview:avatarimageview]; UIView *spinny = [self.view viewWithTag:SPINNY_TAG]; [spinny removeFromSuperview]; [avatarimageview release]; } else { [manager downloadWithURL:url delegate:self]; } NSURL *url2 =[NSURL URLWithString:[NSString stringWithFormat:@"%@%@%@",@"http://myweb/", featuredValueObject.featured_promo_artistcountry , @".png"]]; CGRect flagframe; flagframe.size.width=16; flagframe.size.height=11; flagframe.origin.x=130; flagframe.origin.y=40; NSData* data = [[NSData alloc] initWithContentsOfURL:url2]; UIImage* img = [[UIImage alloc] initWithData:data]; UIImageView *imageflagview = [[UIImageView alloc] initWithImage: img]; imageflagview.frame=flagframe; [self.view addSubview:imageflagview]; [imageflagview release]; imageflagview=nil; [data release]; [img release]; [url release]; artistname =[[UILabel alloc]initWithFrame:CGRectMake(130,75, 200, 15)]; [artistname setFont:[UIFont fontWithName:@"Arial" size:(16.0)]]; artistname.backgroundColor= [UIColor clearColor]; artistname.textColor=[UIColor whiteColor]; artistname.text=featuredValueObject.featured_promo_artistname; [self.view addSubview:artistname]; [artistname release]; hasConstructedFeatured=YES; [featuredValueObject release]; featuredValueObject=nil; }

    Read the article

  • How do I center a UIImageView within a full-screen UIScrollView?

    - by Sebastian Celis
    In my application, I would like to present the user with a full-screen photo viewer much like the one used in the Photos app. This is just for a single photo and as such should be quite simple. I just want the user to be able to view this one photo with the ability to zoom and pan. I have most of it working. And, if I do not center my UIImageView, everything behaves perfectly. However, I really want the UIImageView to be centered on the screen when the image is sufficiently zoomed out. I do not want it stuck to the top-left corner of the scroll view. Once I attempt to center this view, my vertical scrollable area appears to be greater than it should be. As such, once I zoom in a little, I am able to scroll about 100 pixels past the top of the image. What am I doing wrong? @interface MyPhotoViewController : UIViewController <UIScrollViewDelegate> { UIImage* photo; UIImageView *imageView; } - (id)initWithPhoto:(UIImage *)aPhoto; @end @implementation MyPhotoViewController - (id)initWithPhoto:(UIImage *)aPhoto { if (self = [super init]) { photo = [aPhoto retain]; // Some 3.0 SDK code here to ensure this view has a full-screen // layout. } return self; } - (void)dealloc { [photo release]; [imageView release]; [super dealloc]; } - (void)loadView { // Set the main view of this UIViewController to be a UIScrollView. UIScrollView *scrollView = [[UIScrollView alloc] init]; [self setView:scrollView]; [scrollView release]; } - (void)viewDidLoad { [super viewDidLoad]; // Initialize the scroll view. CGSize photoSize = [photo size]; UIScrollView *scrollView = (UIScrollView *)[self view]; [scrollView setDelegate:self]; [scrollView setBackgroundColor:[UIColor blackColor]]; // Create the image view. We push the origin to (0, -44) to ensure // that this view displays behind the navigation bar. imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, -44.0, photoSize.width, photoSize.height)]; [imageView setImage:photo]; [scrollView addSubview:imageView]; // Configure zooming. CGSize screenSize = [[UIScreen mainScreen] bounds].size; CGFloat widthRatio = screenSize.width / photoSize.width; CGFloat heightRatio = screenSize.height / photoSize.height; CGFloat initialZoom = (widthRatio > heightRatio) ? heightRatio : widthRatio; [scrollView setMaximumZoomScale:3.0]; [scrollView setMinimumZoomScale:initialZoom]; [scrollView setZoomScale:initialZoom]; [scrollView setBouncesZoom:YES]; [scrollView setContentSize:CGSizeMake(photoSize.width * initialZoom, photoSize.height * initialZoom)]; // Center the photo. Again we push the center point up by 44 pixels // to account for the translucent navigation bar. CGPoint scrollCenter = [scrollView center]; [imageView setCenter:CGPointMake(scrollCenter.x, scrollCenter.y - 44.0)]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[[self navigationController] navigationBar] setBarStyle:UIBarStyleBlackTranslucent]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [[[self navigationController] navigationBar] setBarStyle:UIBarStyleDefault]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return imageView; } @end

    Read the article

  • NSURLConnection not "firing" until UITableView scrolls..

    - by Simon
    Hi, I've got a UITableView that loads an image asynchronously and places it in the UITableViewCell once it's loaded (I'm using almost the exact same code as in the "LazyTableImages" tutorial). This works fine for all images when I scroll the table, but it's not loading the images that are first in the view. The code is definitely working fine as the class that actually sends the NSURLConnection request is being called correctly (I added an NSLog and it reached the console). The NSURLConnection is just not calling the delegate methods (didReceiveData, connectionDidFinishLoading, etc). Here's my code: HomeController.m - (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]; NSArray *feed = [feeds objectAtIndex: indexPath.row]; /** * Name of person */ [...] /** * Feed entry */ [...] /** * Misc work */ [...] } FeedRecord *feedRecord = [self.entries objectAtIndex:indexPath.row]; if( !feedRecord.image ) { if (self.table.dragging == NO && self.table.decelerating == NO) { [self startIconDownload:feedRecord forIndexPath:indexPath]; } cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"]; } return cell; } - (void)startIconDownload:(FeedRecord *)feedRecord forIndexPath:(NSIndexPath *)indexPath { IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath]; if (iconDownloader == nil) { iconDownloader = [[IconDownloader alloc] init]; iconDownloader.feedRecord = feedRecord; iconDownloader.indexPathInTableView = indexPath; iconDownloader.delegate = self; [imageDownloadsInProgress setObject:iconDownloader forKey:indexPath]; [iconDownloader startDownload]; [iconDownloader release]; } } IconDownload.m #import "IconDownloader.h" #import "FeedRecord.h" #define kAppIconHeight 48 @implementation IconDownloader @synthesize feedRecord; @synthesize indexPathInTableView; @synthesize delegate; @synthesize activeDownload; @synthesize imageConnection; #pragma mark - (void)dealloc { [feedRecord release]; [indexPathInTableView release]; [activeDownload release]; [imageConnection cancel]; [imageConnection release]; [super dealloc]; } - (void)startDownload { NSLog(@"%@ %@",@"Started downloading", feedRecord.profilePicture); // this shows in log self.activeDownload = [NSMutableData data]; // alloc+init and start an NSURLConnection; release on completion/failure NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest: [NSURLRequest requestWithURL: [NSURL URLWithString:feedRecord.profilePicture]] delegate:self]; self.imageConnection = conn; NSLog(@"%@",conn); // this shows in log [conn release]; } - (void)cancelDownload { [self.imageConnection cancel]; self.imageConnection = nil; self.activeDownload = nil; } #pragma mark - #pragma mark Download support (NSURLConnectionDelegate) - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"%@ %@",@"Got data for", feedRecord.profilePicture); [self.activeDownload appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"%@",@"Fail!"); // Clear the activeDownload property to allow later attempts self.activeDownload = nil; // Release the connection now that it's finished self.imageConnection = nil; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"%@ %@",@"Done", feedRecord.profilePicture); // Set appIcon and clear temporary data/image UIImage *image = [[UIImage alloc] initWithData:self.activeDownload]; self.feedRecord.image = image; self.activeDownload = nil; [image release]; // Release the connection now that it's finished self.imageConnection = nil; NSLog(@"%@ %@",@"Our delegate is",delegate); // call our delegate and tell it that our icon is ready for display [delegate feedImageDidLoad:self.indexPathInTableView]; } @end Has anyone else experienced anything like this or can identify an issue with my code? Thanks!

    Read the article

  • NSOperation unable to load data on the TableView

    - by yeohchan
    I have a problem in NSOperation. I tried many ways but it would run behind the screen, but will not make it appear on the my table view. Can anyone help me out with this. I am new to NSOperation. Recents.h #import <UIKit/UIKit.h> #import "FlickrFetcher.h" @interface Recents : UITableViewController { FlickrFetcher *fetcher; NSString *name; NSData *picture; NSString *picName; NSMutableArray *names; NSMutableArray *pics; NSMutableArray *lists; NSArray *namelists; NSOperationQueue *operationQueue; } @property (nonatomic,retain)NSString *name; @property (nonatomic,retain)NSString *picName; @property (nonatomic,retain)NSData *picture; @property (nonatomic,retain)NSMutableArray *names; @property (nonatomic,retain)NSMutableArray *pics; @property(nonatomic,retain)NSMutableArray *lists; @property(nonatomic,retain)NSArray *namelists; @end Recents.m #import "Recents.h" #import "PersonList.h" #import "PhotoDetail.h" @implementation Recents @synthesize picName,picture,name,names,pics,lists,namelists; // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization self.title=@"Recents"; } return self; } - (void)beginLoadingFlickrData{ NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(synchronousLoadFlickrData) object:nil]; [operationQueue addOperation:operation]; [operation release]; } - (void)synchronousLoadFlickrData{ fetcher=[FlickrFetcher sharedInstance]; NSArray *recents=[fetcher recentGeoTaggedPhotos]; [self performSelectorOnMainThread:@selector(didFinishLoadingFlickrDataWithResults:) withObject:recents waitUntilDone:NO]; } - (void)didFinishLoadingFlickrDataWithResults:(NSArray *)recents{ for(NSDictionary *dic in recents){ [names addObject:[fetcher usernameForUserID:[dic objectForKey:@"owner"]]]; if([[dic objectForKey:@"title"]isEqualToString:@""]){ [pics addObject:@"Untitled"]; }else{ [pics addObject:[dic objectForKey:@"title"]]; } NSLog(@"OK!!"); } [self.tableView reloadData]; [self.tableView flashScrollIndicators]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; operationQueue = [[NSOperationQueue alloc] init]; [operationQueue setMaxConcurrentOperationCount:1]; [self beginLoadingFlickrData]; self.tableView.rowHeight = 95; } /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } #pragma mark - #pragma mark Table View Data Source Methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return[names count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease]; } cell.detailTextLabel.text=[names objectAtIndex:indexPath.row]; cell.textLabel.text=[pics objectAtIndex:indexPath.row]; //UIImage *image=[UIImage imageWithData:[self.lists objectAtIndex:indexPath.row]]; //cell.imageView.image=image; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { fetcher=[[FlickrFetcher alloc]init]; PhotoDetail *scroll=[[PhotoDetail alloc]initWithNibName:@"PhotoDetail" bundle:nil]; scroll.titleName=[self.pics objectAtIndex:indexPath.row]; scroll.picture = [UIImage imageWithData:[self.lists objectAtIndex:indexPath.row]]; [self.navigationController pushViewController:scroll animated:YES]; }

    Read the article

  • Received memory warning on setimage

    - by Sam Budda
    This problem has completely stumped me. This is for iOS 5.0 with Xcode 4.2 What's going on is that in my app I let user select images from their photo album and I save those images to apps document directory. Pretty straight forward. What I do then is that in one of the viewController.m files I create multiple UIImageViews and I then set the image for the image view from one of the picture that user selected from apps dir. The problem is that after a certain number of UIImage sets I receive a "Received memory warning". It usually happens when there are 10 pictures. If lets say user selected 11 pictures then the app crashes with Error (GBC). NOTE: each of these images are at least 2.5 MB a piece. After hours of testing I finally narrowed down the problem to this line of code [button1AImgVw setImage:image]; If I comment out that code. All compiles fine and no memory errors happen. But if I don't comment out that code I receive memory errors and eventually a crash. Also note it does process the whole CreateViews IBAction but still crashes at the end. I cannot do release or dealloc since I am running this on iOS 5.0 with Xcode 4.2 Here is the code that I used. Can anyone tell me what did I do wrong? - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self CreateViews]; } -(IBAction) CreateViews { paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask ,YES); documentsPath = [paths objectAtIndex:0]; //here 15 is for testing purposes for (int i = 0; i < 15; i++) { //Lets not get bogged down here. The problem is not here UIImageView *button1AImgVw = [[UIImageView alloc] initWithFrame:CGRectMake(10*i, 10, 10, 10)]; [self.view addSubview:button1AImgVw]; NSMutableString *picStr1a = [[NSMutableString alloc] init]; NSString *dataFile1a = [[NSString alloc] init]; picStr1a = [NSMutableString stringWithFormat:@"%d.jpg", i]; dataFile1a = [documentsPath stringByAppendingPathComponent:picStr1a]; NSData *potraitImgData1a =[[NSData alloc] initWithContentsOfFile:dataFile1a]; UIImage *image = [[UIImage alloc] initWithData:potraitImgData1a]; // This is causing my app to crash if I load more than 10 images! //[button1AImgVw setImage:image]; } NSLog(@"It went to END!"); } //Error I get when 10 images are selected. App does launch and work 2012-10-07 17:12:51.483 ABC-APP[7548:707] It went to END! 2012-10-07 17:12:51.483 ABC-APP [7531:707] Received memory warning. //App crashes with this error when there are 11 images 2012-10-07 17:30:26.339 ABC-APP[7548:707] It went to END! (gdb)

    Read the article

  • Set UIImageView Size?

    - by Tronic
    hi, i have following problem: i generate subviews UIView in an UIScrollView including UIImageViews. NSArray *bilder = [[NSArray alloc] initWithObjects:@"lol.jpg", @"lol2.jpg", nil]; NSArray *added = [[NSMutableArray alloc] init]; UIImageView *tmpView; for (NSString *name in bilder) { UIImage *image = [UIImage imageNamed:name]; tmpView = [[UIImageView alloc] initWithImage:image]; tmpView.contentMode = UIViewContentModeScaleAspectFit; tmpView.frame = CGRectMake(0, 0, 300, 300); [added addObject:tmpView]; [tmpView release]; } CGSize framy = mainFrame.frame.size; NSUInteger x = 0; for (UIView *view in added) { [mainFrame addSubview:view]; view.frame = CGRectMake(framy.height * x++, 0, framy.height, framy.width); } mainFrame.scrollEnabled = YES; mainFrame.pagingEnabled = YES; mainFrame.contentSize = CGSizeMake(framy.height * [added count], framy.width); mainFrame.backgroundColor = [UIColor blackColor]; i get image file names out of an array. now i want to resize the imageview to a specific size, but it won't work. any advice? thanks + regards

    Read the article

  • how to change UITabbar selected color?

    - by RAGOpoR
    according to this post for now, Is apple will also reject this code? and how to implement what apple will approve? @interface UITabBar (ColorExtensions) - (void)recolorItemsWithColor:(UIColor *)color shadowColor:(UIColor *)shadowColor shadowOffset:(CGSize)shadowOffset shadowBlur:(CGFloat)shadowBlur; @end @interface UITabBarItem (Private) @property(retain, nonatomic) UIImage *selectedImage; - (void)_updateView; @end @implementation UITabBar (ColorExtensions) - (void)recolorItemsWithColor:(UIColor *)color shadowColor:(UIColor *)shadowColor shadowOffset:(CGSize)shadowOffset shadowBlur:(CGFloat)shadowBlur { CGColorRef cgColor = [color CGColor]; CGColorRef cgShadowColor = [shadowColor CGColor]; for (UITabBarItem *item in [self items]) if ([item respondsToSelector:@selector(selectedImage)] && [item respondsToSelector:@selector(setSelectedImage:)] && [item respondsToSelector:@selector(_updateView)]) { CGRect contextRect; contextRect.origin.x = 0.0f; contextRect.origin.y = 0.0f; contextRect.size = [[item selectedImage] size]; // Retrieve source image and begin image context UIImage *itemImage = [item image]; CGSize itemImageSize = [itemImage size]; CGPoint itemImagePosition; itemImagePosition.x = ceilf((contextRect.size.width - itemImageSize.width) / 2); itemImagePosition.y = ceilf((contextRect.size.height - itemImageSize.height) / 2); UIGraphicsBeginImageContext(contextRect.size); CGContextRef c = UIGraphicsGetCurrentContext(); // Setup shadow CGContextSetShadowWithColor(c, shadowOffset, shadowBlur, cgShadowColor); // Setup transparency layer and clip to mask CGContextBeginTransparencyLayer(c, NULL); CGContextScaleCTM(c, 1.0, -1.0); CGContextClipToMask(c, CGRectMake(itemImagePosition.x, -itemImagePosition.y, itemImageSize.width, -itemImageSize.height), [itemImage CGImage]); // Fill and end the transparency layer CGContextSetFillColorWithColor(c, cgColor); contextRect.size.height = -contextRect.size.height; CGContextFillRect(c, contextRect); CGContextEndTransparencyLayer(c); // Set selected image and end context [item setSelectedImage:UIGraphicsGetImageFromCurrentImageContext()]; UIGraphicsEndImageContext(); // Update the view [item _updateView]; } } @end

    Read the article

  • Drawing custom graphics on the iPhone: CALayer vs. CGContext

    - by Henry Cooke
    Hi all, I have an application in which I'm doing some custom drawing, a bunch of lines on a gradient background, like so (ignore the text, they're just UILabels): At the moment, that's all done by starting a new CGContext, drawing stuff into it with CGContextDrawLinearGradient and CGContextStrokePath, then finally saving the resulting image with UIGraphicsGetImageFromCurrentImageContext. The positioning info is calculated while I'm laying out those labels, so it'd be a PITA (and duplication of effort) to calculate it all over again when the containing UIView is drawn with drawRect, so I'm drawing it ahead of time into a UIImage. All works fine, so far so good. However, I have a sneaking suspicion that it may be more efficient to use CALayers to do this drawing. My (cursory) understanding of the difference between the two approaches is that a CALayer is more like a bunch of instructions to draw stuff, and so takes up less memory until it's actually drawn onscreen, whereas drawing everything into a UIImage ahead of time means that you've got a sodding great bitmap kicking around in memory all the time, whether it's drawn or not. Is that a correct understanding? What is generally considered to be the best way of drawing custom images on the iPhone?

    Read the article

  • iPhone UIScrollview with UIButtons - how to recreate springboard?

    - by Patrick
    I'm trying to create a springboard-like interface within my app. I'm trying to use UIButtons added to a UIScrollView. The problem I'm running in to is with the buttons not passing any touches to the UIScrollView - if I try to flick/slide and happen to press on the button it doesn't register for the UIScrollView, but if I flick the space between buttons it will work. The buttons do click/work if I touch them. Is there a property or setting that forces the button to send the touch events up to its parent (superview)? Do the buttons need to be added to something else before being added the UIScrollView? Here is my code: //init scrolling area UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 480, 480)]; scrollView.contentSize = CGSizeMake(480, 1000); scrollView.bounces = NO; scrollView.delaysContentTouches = NO; //create background image UIImageView *rowsBackground = [[UIImageView alloc] initWithImage:[self scaleAndRotateImage:[UIImage imageNamed:@"mylongbackground.png"]]]; rowsBackground.userInteractionEnabled = YES; //create button UIButton *btn = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; btn.frame = CGRectMake(100, 850, 150, 150); btn.bounds = CGRectMake(0, 0, 150.0, 150.0); [btn setImage:[self scaleAndRotateImage:[UIImage imageNamed:@"basicbutton.png"]] forState:UIControlStateNormal]; [btn addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside]; //add "stuff" to scrolling area [scrollView addSubview:rowsBackground]; [scrollView addSubview:btn]; //add scrolling area to cocos2d //this is just a UIWindow [[[Director sharedDirector] openGLView] addSubview:scrollView]; //mem-mgmt [rowsBackground release]; [btn release]; [scrollView release];

    Read the article

  • little more help with a CATiledLayer

    - by Brodie4598
    Okay so I am trying to adapt an online tutorial for CATiledLayer to use in my app. The example uses a PDF but I need to display a JPG. I'm getting close, but I just cant figure this out. Should I be using a UIImage or something else? #import <QuartzCore/QuartzCore.h> #import "practiceViewController.h" @implementation practiceViewController - (void)viewDidLoad { [super viewDidLoad]; NSBundle *bundle = [[NSBundle mainBundle]autorelease]; NSString *path = [bundle pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect pageRect = CGRectMake(0, 0, 1600, 2400); CATiledLayer *tiledLayer = [CATiledLayer layer]; tiledLayer.delegate = self; tiledLayer.tileSize = CGSizeMake(1024.0, 1024.0); tiledLayer.levelsOfDetail = 1000; tiledLayer.levelsOfDetailBias = 1000; tiledLayer.frame = pageRect; myContentView = [[UIView alloc] initWithFrame:pageRect]; [myContentView.layer addSublayer:tiledLayer]; CGRect viewFrame = self.view.frame; viewFrame.origin = CGPointZero; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:viewFrame]; scrollView.delegate = self; scrollView.contentSize = pageRect.size; scrollView.maximumZoomScale = 1000; [scrollView addSubview:myContentView]; [self.view addSubview:scrollView]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return myContentView; } - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NEED HE:LP WITH THIS } @end

    Read the article

  • UIActivityIndicatorView is not display at the right time

    - by Alexandre
    I'm making a form that allows the user to enter datas in my IOS application. This form allows the user to enter a lot of repetive datas. So, sometimes, the process takes time and I would like to display a UIActivityIndicatorView during this process. Unfortunalty the spinner appears only one second or less at the end of the process, not at the beginning as expected. There is some code : - (void) manageSpinner{ spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; [spinner setCenter:CGPointMake(self.view.bounds.size.width/2.0, self.view.bounds.size.height/2.0)]; // I do this becau I'm in landscape mode UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.tableView.bounds]; UIImage *image = [UIImage imageNamed:@"dark_gradiant.jpg"]; [imageView setImage:image]; [imageView addSubview:spinner]; [self.tableView addSubview:imageView]; [spinner startAnimating]; } //On click save by the user - (IBAction)save:(id)sender{ //Collect information from the form myObject.name = nameTF.text; [...] if(informations OK[...]){ //Manage spinner [self manageSpinner]; //Add : this is the long process for (int i=0; i<nbRepeatChooseByUser; i++) { [myObject register]; } //Call the delegate that will dismiss the form [self.delegate theSaveButtonOnTheAddMyObjectTVCWasTapped:self]; } } The spinner is called before the adding method but it seems to be set up after the process. Thank you, Alexandre

    Read the article

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