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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-01-2009, 11:06 AM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 28
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
Old 08-02-2009, 05:47 AM   #2 (permalink)
Registered Member
 
kelvinkao's Avatar
 
Join Date: Jul 2009
Location: Los Angeles
Posts: 352
Send a message via AIM to kelvinkao
Default

Try taking out the explo.center = CGPointMake(100, 100); line.
kelvinkao is offline   Reply With Quote
Old 08-02-2009, 03:19 PM   #3 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 28
Default

Quote:
Originally Posted by kelvinkao View Post
Try taking out the explo.center = CGPointMake(100, 100); line.
That makes no differance. The black square just appears at 0, 0.

I don't completely understand why that would have worked anyway.
jetwilson is offline   Reply With Quote
Old 03-16-2010, 03:53 AM   #4 (permalink)
Registered Member
 
finefin's Avatar
 
Join Date: Jun 2009
Posts: 259
Default

I have the same problem:

myUIImageView.animationImages
doesnt work in instances of an UIView.

did you (anyone?) come up with a solution?


EDIT:

Really strange. I believe I'm missing something fundamental here...
When I use an UIView the "normal" way, the animation works fine and the animation array is filled correctly:

Code:
   
    // after creating an myAnimationImages-array
	myUIImageView.animationImages = myAnimationImages;
	NSLog(@"animation: %@", myUIImageView.animationImages);

/* output:

animation: (
    <UIImage: 0xd3ccc0>,
    <UIImage: 0xd39820>,
    <UIImage: 0xd3b530>,
    <UIImage: 0xd398d0>,
)
When I do the same in my UIView-Instance the output is:
Code:
animation: (null)
any help is appreciated.


EDIT II:

oh. and I may add, that setImage using the same array of images works perfectly fine:

Code:
[myUIImageView setImage:[UIImage imageWithContentsOfFile:[myAnimationImages objectAtIndex: 1]]];

EDIT III:

okay. i'm using a NSTimer to shoot off a sequence of "setImage" now.
__________________

I help you, you buy my app - you help me, I buy your app

PARALLAX, The Book Of Sayings - chopped up edition! (HD),omicron,
Canupa Band deluxe (universal), Canupa Band FREE!, Your Face --- follow me on twitter

Last edited by finefin; 03-16-2010 at 09:07 AM.
finefin is offline   Reply With Quote
Reply

Bookmarks

Tags
animation, subclassing uiview, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 262
22 members and 240 guests
ADY, AragornSG, bookesp, chillyh, dacapo, Dani77, Davey555, Desert Diva, Dominus, glenn_sayers, HemiMG, JasonR, LEARN2MAKE, M.A.S., marshusensei, mer10, nobre84, Oral B, prchn4christ, Raggou, Rudy, themathminister
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:30 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0