Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Draw This
($0.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-01-2009, 10:06 AM   #1 (permalink)
jetwilson
Registered Member
 
Join Date: May 2009
Posts: 28
jetwilson is on a distinguished road
Default display animation but get black square?

Hi, Once again another problem has reared its ugly head! I created a basic animation using a UIImageView and wanted to expand on that by making the code more reusable as I want multiples of that animation displayed on the screen

My idea was to create a UIView class called explosionView.m and .h and write the UIImageView animation code there.

This is the init code within the explosionView.m UIView object file:

Code:
- (id)init {
	UIImage *image = [UIImage imageNamed:@"RGB0001.png"];
	CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
	aExplosionView = [[UIImageView alloc] initWithFrame:frame];
	[image release];
	
	self.opaque = NO;
	aExplosionView.animationImages = [NSArray arrayWithObjects:
				[UIImage imageNamed:@"RGB0001.png"],
				[UIImage imageNamed:@"RGB0002.png"],
				[UIImage imageNamed:@"RGB0003.png"],
				[UIImage imageNamed:@"RGB0004.png"],
				[UIImage imageNamed:@"RGB0005.png"],
				[UIImage imageNamed:@"RGB0006.png"],
				[UIImage imageNamed:@"RGB0007.png"],
				[UIImage imageNamed:@"RGB0008.png"],
				[UIImage imageNamed:@"RGB0009.png"],
				[UIImage imageNamed:@"RGB0010.png"],
				[UIImage imageNamed:@"RGB0011.png"],
				[UIImage imageNamed:@"RGB0012.png"],
				[UIImage imageNamed:@"RGB0013.png"],
				[UIImage imageNamed:@"RGB0014.png"],
				[UIImage imageNamed:@"RGB0015.png"],
				nil];
		
	aExplosionView.animationRepeatCount = 1;
	aExplosionView.animationDuration = 1;
	aExplosionView.center = CGPointMake(0, 0);
	[aExplosionView startAnimating];
	
	return self;
}
and in my mainViewController.m I do this to create an instance of the explosionView class in viewDidLoad:

Code:
UIImage *image = [UIImage imageNamed:@"RGB0001.png"];
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
explosionView *explo = [[explosionView alloc] initWithFrame:frame];
[image release];
explo.center = CGPointMake(100, 100);
[self.view addSubview:explo];
I have done this before with UIImages for non-animation images - but when I tried with this animating UIImageView, a black square where my animation should be displayed is displayed. No crash, no nothing. Just a black square. Not terribly useful!

Anyone know what's happening?

Thanks

Jetwilson
jetwilson is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,017
Threads: 93,863
Posts: 401,918
Top Poster: BrianSlick (7,962)
Welcome to our newest member, marce43b
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:57 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.