Search Results

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

Page 10/32 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Memory leak with NSData

    - by Kamchatka
    I'm having a leak with this code without being able to find where it's coming from. This function get called within an autorelease pool. I release the IplImage* image argument. When I run the ObjAlloc tool, it tells me that "NSData* data" is leaking. If I try to manually release the UIImage returned by this function, I get an EXC_BAD_ACCESS error, probably because this UIImage is autoreleased. I'm a bit confused, any hint would be appreciated. Thanks! UIImage *UIImageFromIplImage(IplImage *image) { NSLog(@"IplImage (%d, %d) %d bits by %d channels, %d bytes/row %s", image->width, image->height, image->depth, image->nChannels, image->widthStep, image->channelSeq); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); NSData *data = [NSData dataWithBytes:image->imageData length:image->imageSize]; CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)data); CGImageRef imageRef = CGImageCreate(image->width, image->height, image->depth, image->depth * image->nChannels, image->widthStep, colorSpace, kCGImageAlphaNone|kCGBitmapByteOrderDefault, provider, NULL, false, kCGRenderingIntentDefault); UIImage *ret = [UIImage imageWithCGImage:imageRef]; CGImageRelease(imageRef); CGDataProviderRelease(provider); CGColorSpaceRelease(colorSpace); return ret; }

    Read the article

  • Animation on the iPhone - use image sequence or rotation?

    - by user157733
    I am creating a basic animation for my iPhone app. I have a choice to make between 2 different types of animation. I can use this... NSArray *myImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"myImage1.png"], [UIImage imageNamed:@"myImage2.png"], [UIImage imageNamed:@"myImage3.png"], [UIImage imageNamed:@"myImage4.gif"], nil]; UIImageView *myAnimatedView = [UIImageView alloc]; [myAnimatedView initWithFrame:[self bounds]]; myAnimatedView.animationImages = myImages; myAnimatedView.animationDuration = 0.25; [self addSubview:myAnimatedView]; [myAnimatedView release]; or something like this... [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.5]; // other animations goes here myImage.transform = CGAffineTransformMakeRotation(M_PI*0.5); // other animations goes here [UIView commitAnimations]; I have quite a few of these parts to animate so I want to choose an option which uses the least amount of memory and runds the quickest. Any advice would be great, thanks

    Read the article

  • How i zoom perticular part of UIScrollView?

    - by Rajendra Bhole
    HI, I develop an application in which i want to implement the splash screen, on that splash screen i want to bind the scrollView and UIImage. My code as follow, -(void)splashAnimation{ window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 420)]; //scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; scrollView = [[UIScrollView alloc] initWithFrame:[window bounds]]; scrollView.pagingEnabled = NO; scrollView.bounces = NO; UIImage *image = [UIImage imageNamed:@"splash.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.userInteractionEnabled = NO; [scrollView addSubview:imageView]; [scrollView setDelegate:self]; //[scrollView release]; } - (void)applicationDidFinishLaunching:(UIApplication *)application { [self splashAnimation]; [self initControllers]; [window addSubview:[mainTabBarController view]]; [window makeKeyAndVisible]; } On my given code the one blank window comes up and stay on. I want to on that blank screen bind my splash.png. *The Above problem is solved* My current code is scrollView.pagingEnabled = NO; scrollView.bounces = NO; UIImage *image = [UIImage imageNamed:@"splash.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.userInteractionEnabled = NO; [scrollView addSubview:imageView]; scrollView.maximumZoomScale = 4.0f; scrollView.minimumZoomScale = 1.0f; CGRect rect = CGRectMake(119, 42, 208, 166); [scrollView zoomToRect:rect animated:YES]; [scrollView setDelegate:self]; [window addSubview:scrollView]; [window makeKeyAndVisible]; i want to zoom the particular part of scrollView.

    Read the article

  • iPhone:Tabbar hides when pushing from TableView to UIViewController

    - by user187532
    Hello all, I have four Tab bar items in a Tab bar which is being bottom of the view where i have the TableView. I am adding Tab bar and items programmatically (Refer below code) not through I.B. Click on first three Tab bar items, will show the data in the same TableView itself. But clicking on last Tab bar items will push to another UIViewcontroller and show the data there. The problem here is, when i push to the viewController when clicking on last Tab bar item, main "Tab bar" is getting removed. Tab bar code: UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 376, 320, 44)]; item1 = [[UITabBarItem alloc] initWithTitle:@"First Tab" image:[UIImage imageNamed:@"first.png"] tag:0]; item2 = [[UITabBarItem alloc] initWithTitle:@"Second Tab" image:[UIImage imageNamed:@"second.png"] tag:1]; item3 = [[UITabBarItem alloc] initWithTitle:@"Third Tab" image:[UIImage imageNamed:@"third.png"] tag:2]; item4 = [[UITabBarItem alloc] initWithTitle:@"Fourth Tab" image:[UIImage imageNamed:@"fourth.png"] tag:3]; item5 = [[UITabBarItem alloc] initWithTitle:@"Fifth Tab" image:[UIImage imageNamed:@"fifth.png"] tag:4]; NSArray *items = [NSArray arrayWithObjects: item1,item2,item3,item4, item5, nil]; [tabBar setItems:items animated:NO]; [tabBar setSelectedItem:item1]; tabBar.delegate=self; [self.view addSubview:tabBar]; Push controller code clicking from last Tab bar item: myViewController = [ [MyViewController alloc] initWithNibName:@"MyView" bundle:nil]; myViewController.hidesBottomBarWhenPushed=NO; [[self navigationController] pushViewController:myViewController animated:NO]; I am not seeing bottom Tab bar when i push my current TableView to myViewController. I am seeing full screen view there. I want to see bottom Tab bar always when every tab item clicked. What might be the problem here? Could someone who come across this issue, please share your suggestion to me? Thank you.

    Read the article

  • How to highlight the button untill the next view is changed in iphone?

    - by Pugal Devan
    Hi, I am new to iphone development. I have created five buttons in the view controller. If i clicked the button it goes to the corresponding view. Now i want to display the button in highlighted state when it is clicked. It should go back to the normal state only when i click the other button.(See the image below). I have set the another image for highigthting buttons when i clicked it, but it shows that highlighted state only one sec. Now i want to display the buttons highlighted till another button is clicked. Same like a Tabbar operations.(I have used buttons instead of tabbar for my requirements). Now i have used the following code, void didLoad { [btn1 setImage:[UIImage imageNamed:@"ContentColor.png"] forState:UIControlStateHighlighted]; [btn2 setImage:[UIImage imageNamed:@"bColor.png"] forState:UIControlStateHighlighted]; [btn3 setImage:[UIImage imageNamed:@"ShColor.png"] forState:UIControlStateHighlighted]; [btn4 setImage:[UIImage imageNamed:@"PicturesColor.png"] forState:UIControlStateHighlighted]; [btn5 setImage:[UIImage imageNamed:@"infoColor.png"] forState:UIControlStateHighlighted]; } Please help me out. Thanks.

    Read the article

  • UIView: how to do non-destructive drawing?

    - by Caffeine Coma
    My original question: I'm creating a simple drawing application and need to be able to draw over existing, previously drawn content in my drawRect. What is the proper way to draw on top of existing content without entirely replacing it? Based on answers received here and elsewhere, here is the deal. You should be prepared to redraw the entire rectangle whenever drawRect is called. You cannot prevent the contents from being erased by doing the following: [self setClearsContextBeforeDrawing: NO]; This is merely a hint to the graphics engine that there is no point in having it pre-clear the view for you, since you will likely need to re-draw the whole area anyway. It may prevent your view from being automatically erased, but you cannot depend on it. To draw on top of your view without erasing, do your drawing to an off-screen bitmap context (which is never cleared by the system.) Then in your drawRect, copy from this off-screen buffer to the view. Example: - (id) initWithCoder: (NSCoder*) coder { if (self = [super initWithCoder: coder]) { self.backgroundColor = [UIColor clearColor]; CGSize size = self.frame.size; drawingContext = [self createDrawingBufferContext: size]; } return self; } - (CGContextRef) createOffscreenContext: (CGSize) size { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, size.width, size.height, 8, size.width*4, colorSpace, kCGImageAlphaPremultipliedLast); CGColorSpaceRelease(colorSpace); CGContextTranslateCTM(context, 0, size.height); CGContextScaleCTM(context, 1.0, -1.0); return context; } - (void)drawRect:(CGRect) rect { UIGraphicsPushContext(drawingContext); CGImageRef cgImage = CGBitmapContextCreateImage(drawingContext); UIImage *uiImage = [[UIImage alloc] initWithCGImage:cgImage]; UIGraphicsPopContext(); CGImageRelease(cgImage); [uiImage drawInRect: rect]; [uiImage release]; } TODO: can anyone optimize the drawRect so that only the (usually tiny) modified rectangle region is used for the copy?

    Read the article

  • UICollectionViewCell imageView

    - by Flink
    Code works fine until I changed UIViewController with tableView to UICollectionViewController. Now all cells shows same image, sometimes it flipping to nil. However textLabels are OK. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TourGridCell"; TourGridCell *cell = (TourGridCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; Guide *guideRecord = [self.fetchedResultsController objectAtIndexPath:indexPath]; cell.titleLabel.text = [guideRecord.name uppercaseString]; cell.titleLabel.backgroundColor = [UIColor clearColor]; if ([guideRecord.sights count] > 0) { if ([[guideRecord.sights objectAtIndex:0]valueForKey:@"thumbnail"]) { cell.imageView.image = [UIImage drawImage:[[guideRecord.sights objectAtIndex:0]valueForKey:@"thumbnail"] inImage:[UIImage imageNamed:@"MultiplePhotos"] inRect:CGRectMake(11, 11, 63, 63)]; }else { cell.imageView.image = [UIImage imageNamed:@"placeholder2"]; } NSMutableString *sightsSummary = [NSMutableString stringWithCapacity:[guideRecord.sights count]]; for (Sight *sight in guideRecord.sights) { if ([sight.name length]) { if ([sightsSummary length]) { [sightsSummary appendString:@", "]; } [sightsSummary appendString:sight.name]; } } if ([sightsSummary length]) { [sightsSummary appendString:@"."]; } cell.sightsTextLabel.text = sightsSummary; cell.detailTextLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i", nil) , [guideRecord.sights count]]; cell.detailTextLabel.hidden = NO; // cell.textLabel.alpha = 0.7; NSPredicate *enabledSightPredicate = [NSPredicate predicateWithFormat:@"notify == YES"]; NSArray *sightsEnabled = [[[guideRecord.sights array] filteredArrayUsingPredicate:enabledSightPredicate]mutableCopy]; NSPredicate *visitedSightPredicate = [NSPredicate predicateWithFormat:@"visited == YES"]; NSArray *sightsVisited = [[[guideRecord.sights array] filteredArrayUsingPredicate:visitedSightPredicate]mutableCopy]; if ([sightsEnabled count] > 0) { NSLog(@"green_badge"); cell.notifyIV.image = [UIImage imageNamed:@"green_badge"]; } else if (sightsVisited.count == 0) { NSLog(@"new_badge"); cell.notifyIV.image = [UIImage imageNamed:@"new_badge"]; } else { cell.notifyIV.image = nil; } } else { cell.notifyIV.hidden = YES; // cell.textLabel.textColor = RGB(0, 50, 140); cell.detailTextLabel.hidden = YES; cell.sightsTextLabel.text = nil; } return cell; }

    Read the article

  • iphone sdk conditional in switch function

    - by Oliver
    I'm trying to make a random image appear on the press of a button. So it generates a random number, and the switch algorithm swaps the chosen image with the one in the imgview. but I want a switch in the settings app to toggle which set of images to use. I know pretty much how to do it...it's just that it doesn't work. I'm missing some syntax thing...Please help, stackoverflow? it's my birthday. int Number = rand() %30; NSString *toggleValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"enabled_preference"]; switch (Number) { if (*toggleValue == 0) { case 0: picture.image = [UIImage imageNamed:@"1.png"]; break; case 1: picture.image = [UIImage imageNamed:@"2.png"]; break;} else { case 0: picture.image = [UIImage imageNamed:@"3.png"]; break; case 1: picture.image = [UIImage imageNamed:@"4.png"]; break;} }

    Read the article

  • Masking to Transparent returns empty image

    - by Tibi
    Hi there, I'm trying to put white color in my images to transparent with the following code. Problem is that "CGImageRef maskedTransparent" is blank. I don't understand because the code I'm using is nearly a copy paste from the doc ... Any idea ? (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage { CGImageRef maskRef = maskImage.CGImage; CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider(maskRef), NULL, false); CGImageRef masked = CGImageCreateWithMask([image CGImage], mask); //Array defining min & max RGB values to be transformed to transparent colors. float maskingMinMax[6] = {255, 255, 255, 255, 255, 255}; //masking image to remove range in maskinLinMax CGImageRef maskedTransparent = CGImageCreateWithMaskingColors(masked, maskingMinMax); return [UIImage imageWithCGImage:maskedTransparent]; }

    Read the article

  • Play Animation with specefic Time [iPhone Animation]

    - by Momeks
    Hi , iam trying play animation with xcode,in specefic Time for example after 3 minutes play an animation .. i don't know how coding with NSTimer ! here is my animation codes : NSArray *myImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"myImage1.png"], [UIImage imageNamed:@"myImage2.png"], [UIImage imageNamed:@"myImage3.png"], [UIImage imageNamed:@"myImage4.gif"], nil]; UIImageView *myAnimatedView = [UIImageView alloc]; [myAnimatedView initWithFrame:[self bounds]]; myAnimatedView.animationImages = myImages; myAnimatedView.animationDuration = 0.25; myAnimatedView.animationRepeatCount = 0; [myAnimatedView startAnimating]; [self addSubview:myAnimatedView]; [myAnimatedView release];

    Read the article

  • iPhone memory management

    - by Prazi
    I am newbie to iPhone programming. I am not using Interface Builder in my programming. I have some doubt about memory management, @property topics in iPhone. Consider the following code @interface LoadFlag : UIViewController { UIImage *flag; UIImageView *preview; } @property (nonatomic, retain) UIImageView *preview; @property (nonatomic, retain) UIImage *flag; @implementation @synthesize preview; @synthesize flag; - (void)viewDidLoad { flag = [UIImage imageNamed:@"myImage.png"]]; NSLog(@"Preview: %d\n",[preview retainCount]); //Count: 0 but shouldn't it be 1 as I am retaining it in @property in interface file preview=[[UIImageView alloc]init]; NSLog(@"Count: %d\n",[preview retainCount]); //Count: 1 preview.frame=CGRectMake(0.0f, 0.0f, 100.0f, 100.0f); preview.image = flag; [self.view addSubview:preview]; NSLog(@"Count: %d\n",[preview retainCount]); //Count: 2 [preview release]; NSLog(@"Count: %d\n",[preview retainCount]); //Count: 1 } When & Why(what is the need) do I have to set @property with retain (in above case for UIImage & UIImageView) ? I saw this statement in many sample programs but didn't understood the need of it. When I declare @property (nonatomic, retain) UIImageView *preview; statement the retain Count is 0. Why doesn't it increase by 1 inspite of retaining it in @property. Also when I declare [self.view addSubview:preview]; then retain Count increments by 1 again. In this case does the "Autorelease pool" releases for us later or we have to take care of releasing it. I am not sure but I think that the Autorelease should handle it as we didn't explicitly retained it so why should we worry of releasing it. Now, after the [preview release]; statement my count is 1. Now I don't need UIImageView anymore in my program so when and where should I release it so that the count becomes 0 and the memory gets deallocated. Again, I am not sure but I think that the Autorelease should handle it as we didn't explicitly retained it so why should we worry of releasing it. What will happen if I release it in -(void) dealloc method In the statement - flag = [UIImage imageNamed:@"myImage.png"]]; I haven't allocated any memory to flag but how can I still use it in my program. In this case if I do not allocate memory then who allocates & deallocates memory to it or is the "flag" just a reference pointing to - [UIImage imageNamed:@"myImage.png"]];. If it is a reference only then do i need to release it. Thanks in advance.

    Read the article

  • Animating UIImageView iPhone

    - by Fred Dpn
    Hi, i'm having trouble about animating an Image in a UIImageView. I've created an image view in interface builder and linked it to its iboutlet. Here is my code. @interface Game : UIViewController <UIAccelerometerDelegate>{ IBOutlet UIImageView *diying; } @property (nonatomic, retain) UIImageView *diying; In the viewDidLoad method i've written this code NSArray * imageArray = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"Die1.gif"], [UIImage imageNamed:@"Die2.gif"], [UIImage imageNamed:@"Die3.gif"], [UIImage imageNamed:@"Die4.gif"], nil]; diying.animationImages = imageArray; diying.animationDuration = 1.1; diying.contentMode = UIViewContentModeBottomLeft; [diying startAnimating]; [super viewDidLoad]; which is a adaptation of what i've found here : http://icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/ NB : those .gif files are simple images and are not animated. I did the tutorial and it worked fine but i can't figure out why it my adaptation doesn't work !

    Read the article

  • Easier way to add lots of images to an array

    - by Sam Jarman
    Hey Guys In an effort to 'clean up' my code - I was wondering if this could be made simpler. I have 32 images and I was adding them like this [theCarPics addObject:[UIImage imageNamed:@"1.jpg"]]; [theCarPics addObject:[UIImage imageNamed:@"2.jpg"]]; //... [theCarPics addObject:[UIImage imageNamed:@"32.jpg"]]; is there a simpler way? loop perhaps? Any ideas would be appreciated guys Thanks Sam

    Read the article

  • UI View Controller crashes after interruption

    - by nosuic
    Given the multitasking of iOS I thought it wouldn't be a pain to pause and resume my app, by pressing the home button or due to a phone call, but for a particular view controller it crashes. The navigation bar is working fine i.e. when I tap "Back" it's ok, but if I try to tap controls of the displayed UI View Controller then I get EXC_BAD_ACCESS.. =/ Please find the code of my problematic View Controller below. I'm not very sure about it myself, because I used loadView to build its View, but apart from this interruption problem it works fine. StoreViewController.h #import <UIKit/UIKit.h> @protocol StoreViewDelegate <NSObject> @optional - (void)DirectionsClicked:(double)lat:(double)lon; @end @interface StoreViewController : UIViewController { double latitude; double longitude; NSString *description; NSString *imageURL; short rating; NSString *storeType; NSString *offerType; UIImageView *imageView; UILabel *descriptionLabel; id<StoreViewDelegate> storeViewDel; } @property (nonatomic) double latitude; @property (nonatomic) double longitude; @property (nonatomic) short rating; @property (nonatomic,retain) NSString *description; @property (nonatomic,retain) NSString *imageURL; @property (nonatomic,retain) NSString *storeType; @property (nonatomic,retain) NSString *offerType; @property (assign) id<StoreViewDelegate> storeViewDel; @end StoreViewController.m #import "StoreViewController.h" #import <QuartzCore/QuartzCore.h> @interface StoreViewController() -(CGSize) calcLabelSize:(NSString *)string withFont:(UIFont *)font maxSize:(CGSize)maxSize; @end @implementation StoreViewController @synthesize storeViewDel, longitude, latitude, description, imageURL, rating, offerType, storeType; - (void)mapsButtonClicked:(id)sender { } - (void)loadView { UIView *storeView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; // Colours UIColor *lightBlue = [[UIColor alloc] initWithRed:(189.0f / 255.0f) green:(230.0f / 255.0f) blue:(252.0f / 255.0f) alpha:1.0f]; UIColor *darkBlue = [[UIColor alloc] initWithRed:(28.0f/255.0f) green:(157.0f/255.0f) blue:(215.0f/255.0f) alpha:1.0f]; // Layout int width = self.navigationController.view.frame.size.width; int height = self.navigationController.view.frame.size.height; float firstRowHeight = 100.0f; int margin = width / 20; int imgWidth = (width - 3 * margin) / 2; // Set ImageView imageView = [[UIImageView alloc] initWithFrame:CGRectMake(margin, margin, imgWidth, imgWidth)]; CALayer *imgLayer = [imageView layer]; [imgLayer setMasksToBounds:YES]; [imgLayer setCornerRadius:10.0f]; [imgLayer setBorderWidth:4.0f]; [imgLayer setBorderColor:[lightBlue CGColor]]; // Load default image NSData *imageData = [NSData dataWithContentsOfFile:@"thumb-null.png"]; UIImage *image = [UIImage imageWithData:imageData]; [imageView setImage:image]; [storeView addSubview:imageView]; // Set Rating UIImageView *ratingView = [[UIImageView alloc] initWithFrame:CGRectMake(3 * width / 4 - 59.0f, margin, 118.0f, 36.0f)]; UIImage *ratingImage = [UIImage imageNamed:@"bb-rating-0.png"]; [ratingView setImage:ratingImage]; [ratingImage release]; [storeView addSubview:ratingView]; // Set Get Directions button UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(3 * width / 4 - 71.5f, 36.0f + 2*margin, 143.0f, 63.0f)]; [btn addTarget:self action:@selector(mapsButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; UIImage *mapsImgUp = [UIImage imageNamed:@"bb-maps-up.png"]; [btn setImage:mapsImgUp forState:UIControlStateNormal]; [mapsImgUp release]; UIImage *mapsImgDown = [UIImage imageNamed:@"bb-maps-down.png"]; [btn setImage:mapsImgDown forState:UIControlStateHighlighted]; [mapsImgDown release]; [storeView addSubview:btn]; [btn release]; // Set Description Text UIScrollView *descriptionView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, imgWidth + 2 * margin, width, height - firstRowHeight)]; descriptionView.backgroundColor = lightBlue; CGSize s = [self calcLabelSize:description withFont:[UIFont systemFontOfSize:18.0f] maxSize:CGSizeMake(width, 9999.0f)]; descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(margin, margin, width - 2 * margin, s.height)]; descriptionLabel.lineBreakMode = UILineBreakModeWordWrap; descriptionLabel.numberOfLines = 0; descriptionLabel.font = [UIFont systemFontOfSize:18.0f]; descriptionLabel.textColor = darkBlue; descriptionLabel.text = description; descriptionLabel.backgroundColor = lightBlue; [descriptionView addSubview:descriptionLabel]; [storeView addSubview:descriptionView]; [descriptionLabel release]; [lightBlue release]; [darkBlue release]; self.view = storeView; [storeView release]; } - (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 { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [imageView release]; [descriptionLabel release]; [super dealloc]; } @end Any suggestions ? Thank you, F.

    Read the article

  • How i display my scrollView instaed of splash screen?

    - by Rajendra Bhole
    HI, I develop an application in which i want to implement the splash screen, on that splash screen i want to bind the scrollView and UIImage. My code as follow, -(void)splashAnimation{ window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 420)]; //scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; scrollView = [[UIScrollView alloc] initWithFrame:[window bounds]]; scrollView.pagingEnabled = NO; scrollView.bounces = NO; UIImage *image = [UIImage imageNamed:@"splash.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.userInteractionEnabled = NO; [scrollView addSubview:imageView]; [scrollView setDelegate:self]; //[scrollView release]; /* window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 420)]; UIView *splashView = [[UIView alloc] initWithFrame:[window bounds]]; UIImage *image = [UIImage imageNamed:@"splash.png"]; [splashView addSubview: [[UIImageView alloc] initWithImage:image]]; [window addSubview:splashView]; [window makeKeyAndVisible]; [window removeFromSuperview]; } - (void)applicationDidFinishLaunching:(UIApplication *)application { [self splashAnimation]; [self initControllers]; [window addSubview:[mainTabBarController view]]; [window makeKeyAndVisible]; } On my given code the one blank window comes up and stay on. I want to on that blank screen bind my splash.png.

    Read the article

  • Show image from url in uiimageview

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

    Read the article

  • Cycle backwards through NSArray

    - by dot
    Hello! I'm trying to cycle backwards through an array by clicking a button. My current code is close, but doesn't quite work. - (void)viewDidLoad { self.imageNames = [NSArray arrayWithObjects:@"MyFirstImage", @"AnotherImage", nil]; currentImageIndex = 0; [super viewDidLoad]; } ...what works: - (IBAction)change { UIImage* imageToShow = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[imageNames objectAtIndex:currentImageIndex] ofType:@"png"]; currentImageIndex++; if (currentImageIndex >= imageNames.count) { currentImageIndex = 0; } } ...and what isn't working: - (IBAction)changeBack { UIImage* imageToShow = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[imageNames objectAtIndex:currentImageIndex] ofType:@"png"]; currentImageIndex--; if (currentImageIndex >= imageNames.count) { currentImageIndex = 0; } } Any help is gladly appreciated! Thanks!

    Read the article

  • Pass Variables In Inheritance (Obj - C)

    - by Marmik Shah
    I working on a project in Obj-C where i have a base class (ViewController) and a Derived Class (MultiPlayer). Now i have declared certain variables and properties in the base class. My properties are getting accessed from the derived class but im not able to access the variables (int,char and bool type). I'm completely new to Obj-C so i have no clue whats wrong. I have used the data types which are used in C and C++. Is there some specific way to declare variables in Obj-C?? If so, How? Here are my files ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (weak,nonatomic) IBOutlet UIImageView* backGroungImage; @property (strong,nonatomic) IBOutlet UIImageView *blockView1; @property (strong,nonatomic) IBOutlet UIImageView *blockView2; @property (strong,nonatomic) IBOutlet UIImageView *blockView3; @property (strong,nonatomic) IBOutlet UIImageView *blockView4; @property (strong,nonatomic) IBOutlet UIImageView *blockView5; @property (strong,nonatomic) IBOutlet UIImageView *blockView6; @property (strong,nonatomic) IBOutlet UIImageView *blockView7; @property (strong,nonatomic) IBOutlet UIImageView *blockView8; @property (strong,nonatomic) IBOutlet UIImageView *blockView9; @property (strong,nonatomic) UIImage *x; @property (strong,nonatomic) UIImage *O; @property (strong,nonatomic) IBOutlet UIImageView* back1; @property (strong,nonatomic) IBOutlet UIImageView* back2; @end ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController int chooseTheBackground = 0; int movesToDecideXorO = 0; int winningArrayX[3]; int winningArrayO[3]; int blocksTotal[9] = {8,3,4,1,5,9,6,7,2}; int checkIfContentInBlocks[9] = {0,0,0,0,0,0,0,0,0}; char determineContentInBlocks[9] = {' ',' ',' ',' ',' ',' ',' ',' ',' '}; bool player1Win = false; bool player2Win = false; bool playerWin = false; bool computerWin = false; - (void)viewDidLoad { [super viewDidLoad]; if(chooseTheBackground==0) { UIImage* backImage = [UIImage imageNamed:@"MainBack1.png"]; _backGroungImage.image=backImage; } if(chooseTheBackground==1) { UIImage* backImage = [UIImage imageNamed:@"MainBack2.png"]; _backGroungImage.image=backImage; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end I am not able to use the above declared variables in my derived classes!

    Read the article

  • how can i set the background color of a particular button in iphone ?

    - by suchita
    for this I used btnName1 = [ColorfulButton buttonWithType:UIButtonTypeRoundedRect]; btnName1.frame=CGRectMake(45,146,220,40); [btnName1 setTitle:@"Continue" forState:UIControlStateNormal]; [btnName1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [btnName1 setImage:[UIImage imageNamed:@"green.png"] forState:UIControlStateNormal]; UIImage *img =[UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"greenish" ofType:@"png"]]; UIImage *strechableImage = [img stretchableImageWithLeftCapWidth:12 topCapHeight:0]; [btnName1 setBackgroundImage:strechableImage forState:UIControlStateNormal]; [btnName1 setNeedsDisplay]; [InfoView addSubview:btnName1]; it's correctly working on iphone simulator but not on ipod(color not show in ipod)

    Read the article

  • iPhone Image Processing--matrix convolution

    - by James
    I am implementing a matrix convolution blur on the iPhone. The following code converts the UIImage supplied as an argument of the blur function into a CGImageRef, and then stores the RGBA values in a standard C char array. CGImageRef imageRef = imgRef.CGImage; int width = imgRef.size.width; int height = imgRef.size.height; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); unsigned char *pixels = malloc((height) * (width) * 4); NSUInteger bytesPerPixel = 4; NSUInteger bytesPerRow = bytesPerPixel * (width); NSUInteger bitsPerComponent = 8; CGContextRef context = CGBitmapContextCreate(pixels, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); CGContextRelease(context); Then the pixels values stored in the pixels array are convolved, and stored in another array. unsigned char *results = malloc((height) * (width) * 4); Finally, these augmented pixel values are changed back into a CGImageRef, converted to a UIImage, and the returned at the end of the function with the following code. context = CGBitmapContextCreate(results, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGImageRef finalImage = CGBitmapContextCreateImage(context); UIImage *newImage = [UIImage imageWithCGImage:CGBitmapContextCreateImage(context)]; CGImageRelease(finalImage); NSLog(@"edges found"); free(results); free(pixels); CGColorSpaceRelease(colorSpace); return newImage; This works perfectly, once. Then, once the image is put through the filter again, very odd, unprecedented pixel values representing input pixel values that don't exist, are returned. Is there any reason why this should work the first time, but then not afterward? Beneath is the entirety of the function. -(UIImage*) blur:(UIImage*)imgRef { CGImageRef imageRef = imgRef.CGImage; int width = imgRef.size.width; int height = imgRef.size.height; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); unsigned char *pixels = malloc((height) * (width) * 4); NSUInteger bytesPerPixel = 4; NSUInteger bytesPerRow = bytesPerPixel * (width); NSUInteger bitsPerComponent = 8; CGContextRef context = CGBitmapContextCreate(pixels, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); CGContextRelease(context); height = imgRef.size.height; width = imgRef.size.width; float matrix[] = {0,0,0,0,1,0,0,0,0}; float divisor = 1; float shift = 0; unsigned char *results = malloc((height) * (width) * 4); for(int y = 1; y < height; y++){ for(int x = 1; x < width; x++){ float red = 0; float green = 0; float blue = 0; int multiplier=1; if(y>0 && x>0){ int index = (y-1)*width + x; red = matrix[0]*multiplier*(float)pixels[4*(index-1)] + matrix[1]*multiplier*(float)pixels[4*(index)] + matrix[2]*multiplier*(float)pixels[4*(index+1)]; green = matrix[0]*multiplier*(float)pixels[4*(index-1)+1] + matrix[1]*multiplier*(float)pixels[4*(index)+1] + matrix[2]*multiplier*(float)pixels[4*(index+1)+1]; blue = matrix[0]*multiplier*(float)pixels[4*(index-1)+2] + matrix[1]*multiplier*(float)pixels[4*(index)+2] + matrix[2]*multiplier*(float)pixels[4*(index+1)+2]; index = (y)*width + x; red = red+ matrix[3]*multiplier*(float)pixels[4*(index-1)] + matrix[4]*multiplier*(float)pixels[4*(index)] + matrix[5]*multiplier*(float)pixels[4*(index+1)]; green = green + matrix[3]*multiplier*(float)pixels[4*(index-1)+1] + matrix[4]*multiplier*(float)pixels[4*(index)+1] + matrix[5]*multiplier*(float)pixels[4*(index+1)+1]; blue = blue + matrix[3]*multiplier*(float)pixels[4*(index-1)+2] + matrix[4]*multiplier*(float)pixels[4*(index)+2] + matrix[5]*multiplier*(float)pixels[4*(index+1)+2]; index = (y+1)*width + x; red = red+ matrix[6]*multiplier*(float)pixels[4*(index-1)] + matrix[7]*multiplier*(float)pixels[4*(index)] + matrix[8]*multiplier*(float)pixels[4*(index+1)]; green = green + matrix[6]*multiplier*(float)pixels[4*(index-1)+1] + matrix[7]*multiplier*(float)pixels[4*(index)+1] + matrix[8]*multiplier*(float)pixels[4*(index+1)+1]; blue = blue + matrix[6]*multiplier*(float)pixels[4*(index-1)+2] + matrix[7]*multiplier*(float)pixels[4*(index)+2] + matrix[8]*multiplier*(float)pixels[4*(index+1)+2]; red = red/divisor+shift; green = green/divisor+shift; blue = blue/divisor+shift; if(red<0){ red=0; } if(green<0){ green=0; } if(blue<0){ blue=0; } if(red>255){ red=255; } if(green>255){ green=255; } if(blue>255){ blue=255; } int realPos = 4*(y*imgRef.size.width + x); results[realPos] = red; results[realPos + 1] = green; results[realPos + 2] = blue; results[realPos + 3] = 1; }else { int realPos = 4*((y)*(imgRef.size.width) + (x)); results[realPos] = 0; results[realPos + 1] = 0; results[realPos + 2] = 0; results[realPos + 3] = 1; } } } context = CGBitmapContextCreate(results, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGImageRef finalImage = CGBitmapContextCreateImage(context); UIImage *newImage = [UIImage imageWithCGImage:CGBitmapContextCreateImage(context)]; CGImageRelease(finalImage); free(results); free(pixels); CGColorSpaceRelease(colorSpace); return newImage;} THANKS!!!

    Read the article

  • Custom Annotation not showing all

    - by funatsg
    Okay, i have a number of pins on the mapkit. These pins showing different types of attractions. (E.g Parks, Farms and etc) I want to add custom images for these different types of pin. Parks have a park image and vice versa. However, when i added in, not all the images are showing successfully. For example, in parks, it should have 5 pins, but the image only came up in 2 pins, whereas other 3 is in default red pins. But if i used colours to differentiate them. For example, [pinsetPinColor:MKPinAnnotationColorGreen]; It works! Anyone knows what is the problem? Relevant codes below. Tell me if you need more. thanks! - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{ if ([annotation isKindOfClass:MKUserLocation.class]) { //user location view is being requested, //return nil so it uses the default which is a blue dot... return nil; } //NSLog(@"View for Annotation is called"); MKPinAnnotationView *pin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil]; pin.userInteractionEnabled=TRUE; MapEvent* event = (MapEvent*)annotation; NSLog(@"thetype: %@", event.thetype); if ([event.thetype isEqualToString:@"adv"]) { //[pin setPinColor:MKPinAnnotationColorGreen]; pin.image = [UIImage imageNamed:@"padv.png"]; } else if ([event.thetype isEqualToString:@"muse"]){ //[pin setPinColor:MKPinAnnotationColorPurple]; pin.image = [UIImage imageNamed:@"pmuse.png"]; } else if ([event.thetype isEqualToString:@"nightlife"]){ pin.image = [UIImage imageNamed:@"pnight.png"]; } else if ([event.thetype isEqualToString:@"parks"]){ pin.image = [UIImage imageNamed:@"ppark.png"]; } else if ([event.thetype isEqualToString:@"farms"]){ pin.image = [UIImage imageNamed:@"pfarm.png"]; } else { [pin setPinColor:MKPinAnnotationColorRed]; } pin.canShowCallout = YES; pin.animatesDrop = YES; UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [rightButton addTarget:self action:@selector(clickAnnotation:) forControlEvents:UIControlEventTouchUpInside]; [rightButton setTitle:event.uniqueID forState:UIControlStateNormal]; pin.rightCalloutAccessoryView = rightButton; return pin; }

    Read the article

  • UIImageWriteToSavedPhotosAlbum showing memory leak with iPhone connected to Instruments

    - by user168739
    Hi, I'm using version 3.0.1 of the SDK. With the iPhone connected to Instruments I'm getting a memory leak when I call UIImageWriteToSavedPhotosAlbum. Below is my code: NSString *gnTmpStr = [NSString stringWithFormat:@"%d", count]; UIImage *ganTmpImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:gnTmpStr ofType:@"jpg"]]; // Request to save the image to camera roll UIImageWriteToSavedPhotosAlbum(ganTmpImage, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil); and the selector method - (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { NSString *message; NSString *title; if (!error) { title = @"Wallpaper"; message = @"Wallpaper Saved"; } else { title = @"Error"; message = [error description]; } UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } Am I forgetting to release something once the image has been saved and the selector method imageSavedToPhotosAlbum is called? Or is there a possible known issue with UIImageWriteToSavedPhotosAlbum? Here is the stack trace from Instruments: Leaked Object: GeneralBlock-3584 size: 3.50 KB 30 MyApp start 29 MyApp main /Users/user/Desktop/MyApp/main.m:14 28 UIKit UIApplicationMain 27 UIKit -[UIApplication _run] 26 GraphicsServices GSEventRunModal 25 CoreFoundation CFRunLoopRunInMode 24 CoreFoundation CFRunLoopRunSpecific 23 GraphicsServices PurpleEventCallback 22 UIKit _UIApplicationHandleEvent 21 UIKit -[UIApplication sendEvent:] 20 UIKit -[UIWindow sendEvent:] 19 UIKit -[UIWindow _sendTouchesForEvent:] 18 UIKit -[UIControl touchesEnded:withEvent:] 17 UIKit -[UIControl(Internal) _sendActionsForEvents:withEvent:] 16 UIKit -[UIControl sendAction:to:forEvent:] 15 UIKit -[UIApplication sendAction:toTarget:fromSender:forEvent:] 14 UIKit -[UIApplication sendAction:to:from:forEvent:] 13 CoreFoundation -[NSObject performSelector:withObject:withObject:] 12 UIKit -[UIBarButtonItem(Internal) _sendAction:withEvent:] 11 UIKit -[UIApplication sendAction:to:from:forEvent:] 10 CoreFoundation -[NSObject performSelector:withObject:withObject:] 9 MyApp -[FlipsideViewController svPhoto] /Users/user/Desktop/MyApp/Classes/FlipsideViewController.m:218 8 0x317fa528 7 0x317e3628 6 0x317e3730 5 0x317edda4 4 0x3180fc74 3 Foundation +[NSThread detachNewThreadSelector:toTarget:withObject:] 2 Foundation -[NSThread start] 1 libSystem.B.dylib pthread_create 0 libSystem.B.dylib malloc I did a test with a new project and only added this code below in the viewDidLoad: NSString *gnTmpStr = [NSString stringWithFormat:@"DefaultTest"]; UIImage *ganTmpImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:gnTmpStr ofType:@"png"]]; // Request to save the image to camera roll UIImageWriteToSavedPhotosAlbum(ganTmpImage, nil, nil, nil); The same leak shows up right after the app loads Thank you for the help. Bryan

    Read the article

  • UITabBarContrtoller achieve from a different class in iPhone

    - by baluedo
    Hi! I have the following problem: There is a class that includes five tabs in the following way: mainMenuClient.h #import <UIKit/UIKit.h> @interface MainMenuClient : UIViewController { UITabBarController *tabBarController; } @property (nonatomic, retain) UITabBarController *tabBarController; @end mainMenuClient.m -(void)viewDidLoad { UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; contentView.backgroundColor = [UIColor blackColor]; self.view = contentView; [contentView release]; ContactListTab *contactTab = [[ContactListTab alloc] init]; ChatTab *chat = [[ChatTab alloc]init]; DialerTab *dialer = [[DialerTab alloc]init]; MenuTab *menu = [[MenuTab alloc]init]; TesztingFile *teszting = [[TesztingFile alloc]init]; contactTab.title = @"Contact List"; chat.title = @"Chat"; dialer.title = @"Dialer"; menu.title = @"Menu"; teszting.title = @"TesztTab"; contactTab.tabBarItem.image = [UIImage imageNamed:@"Contacts_icon.png"]; chat.tabBarItem.image = [UIImage imageNamed:@"Chat_icon.png"]; dialer.tabBarItem.image = [UIImage imageNamed:@"Dialer_icon.png"]; menu.tabBarItem.image = [UIImage imageNamed:@"Menu_icon.png"]; teszting.tabBarItem.image = [UIImage imageNamed:@"Contacts_icon.png"]; chat.tabBarItem.badgeValue = @"99"; tabBarController = [[UITabBarController alloc]init]; tabBarController.view.frame = CGRectMake(0, 0, 320, 460); [tabBarController setViewControllers:[NSArray arrayWithObjects:contactTab, chat, dialer, menu, teszting, nil]]; [contactTab release]; [chat release]; [dialer release]; [menu release]; [teszting release]; [self.view addSubview:tabBarController.view]; [super viewDidLoad]; } In the contactTab class there are a UITableViewController. contactTab.h - (void)updateCellData; - (void)configureCell:(UITableViewCell *)cell forIndexPath:(NSIndexPath *)indexPath; There is a third class, which I would like to achieve is a method of UITableViewController's (from ContactTab). So far I tried this: When I tried to achieve the UItabbarController: MainMenuClient *menu; UITabBarController *tabBarControllerchange = [[UITabBarController alloc] init]; tabBarControllerchange = menu.tabBarController; [tabBarControllerchange setSelectedIndex:0]; When I tried to achieve the UITableViewController: ContactListTab *contactListTab; [contactListTab updateCellData]; Does anybody have an idea for this problem? Thanks. Balazs.

    Read the article

  • Memory issues - Living vs. overall -> app is killed

    - by D33
    I'm trying to check my applications memory issues in Instruments. When I load the application I play some sounds and show some animations in UIImageViews. To save some memory I load the sounds only when I need it and when I stop playing it I free it from the memory. problem 1: My application is using about 5.5MB of Living memory. BUT The Overall section is growing after start to 20MB and then it's slowly growing (about 100kB/sec). But responsible Library is OpenAL (OAL::Buffer), dyld (_dyld_start)-I am not sure what this really is, and some other stuff like ft_mem_qrealloc, CGFontStrikeSetValue, … problem 2: When the overall section breaks about 30MB, application crashes (is killed). According to the facts I already read about overall memory, it means then my all allocations and deallocation is about 30MB. But I don't really see the problem. When I need some sound for example I load it to the memory and when I don't need it anymore I release it. But that means when I load 1MB sound, this operation increase overall memory usage with 2MB. Am I right? And when I load 10 sounds my app crashes just because the fact my overall is too high even living is still low??? I am very confused about it. Could someone please help me clear it up? (I am on iOS 5 and using ARC) SOME CODE: creating the sound OpenAL: MYOpenALSound *sound = [[MyOpenALSound alloc] initWithSoundFile:filename willRepeat:NO]; if(!sound) return; [soundDictionary addObject:sound]; playing: [sound play]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, ((sound.duration * sound.pitch) + 0.1) * NSEC_PER_SEC), dispatch_get_current_queue(), ^{ [soundDictionary removeObjectForKey:[NSNumber numberWithInt:soundID]]; }); } creating the sound with AVAudioPlayer: [musics replaceObjectAtIndex:ID_MUSIC_MAP withObject:[[Music alloc] initWithFilename:@"mapMusic.mp3" andWillRepeat:YES]]; pom = [musics objectAtIndex:musicID]; [pom playMusic]; and stop and free it: [musics replaceObjectAtIndex:ID_MUSIC_MAP withObject:[NSNull null]]; AND IMAGE ANIMATIONS: I load images from big PNG file (this is realated also to my other topic : Memory warning - UIImageView and its animations) I have few UIImageViews and by time I'm setting animation arrays to play Animations... UIImage *source = [[UIImage alloc] initWithCGImage:[[UIImage imageNamed:@"imageSource.png"] CGImage]]; cutRect = CGRectMake(0*dimForImg.width,1*dimForImg.height,dimForImg.width,dimForImg.height); image1 = [[UIImage alloc] initWithCGImage:CGImageCreateWithImageInRect([source CGImage], cutRect)]; cutRect = CGRectMake(1*dimForImg.width,1*dimForImg.height,dimForImg.width,dimForImg.height); ... image12 = [[UIImage alloc] initWithCGImage:CGImageCreateWithImageInRect([source CGImage], cutRect)]; NSArray *images = [[NSArray alloc] initWithObjects:image1, image2, image3, image4, image5, image6, image7, image8, image9, image10, image11, image12, image12, image12, nil]; and this array I just use simply like : myUIImageView.animationImages = images, ... duration -> startAnimating

    Read the article

  • Error when passing data between views

    - by Kristoffer Bilek
    I'm using a plist (array of dictionaries) to populate a tableview. Now, when a cell i pressed, I want to pass the reprecented dictionary to the detail view with a segue. It's working properly to fill the tableview, but how do I send the same value to the detail view? This is my try: #import "WinesViewController.h" #import "WineObject.h" #import "WineCell.h" #import "WinesDetailViewController.h" @interface WinesViewController () @end @implementation WinesViewController - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; } - (void)viewDidUnload { [super viewDidUnload]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } #pragma mark - Table view data source - (void)viewWillAppear:(BOOL)animated { wine = [[WineObject alloc] initWithLibraryName:@"Wine"]; self.title = @"Vinene"; [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [wine libraryCount]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"wineCell"; WineCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // Configure the cell... cell.nameLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Name"]; cell.districtLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"District"]; cell.countryLabel.text = [[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Country"]; cell.bottleImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Image"]]; cell.flagImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Flag"]]; cell.fyldeImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Fylde"]]; cell.friskhetImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Friskhet"]]; cell.garvesyreImageView.image = [UIImage imageNamed:[[wine libraryItemAtIndex:indexPath.row] valueForKey:@"Garvesyre"]]; return cell; } #pragma mark - Table view delegate - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"DetailSegue"]) { NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow]; WinesDetailViewController *winesdetailViewController = [segue destinationViewController]; //Here comes the error line: winesdetailViewController.winedetailName = [wine objectAtIndex:indexPath.row] valueForKey:@"Name"]; } } I get one error for: winesdetailViewController.winedetailName = [wine objectAtIndex:indexPath.row] valueForKey:@"Name"]; Use of undeclaired identifier: indexPath. did you mean NSIndexPath? I think I've missed something important here..

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >