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)

AppFusion - 6 in 1!
($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 01-27-2012, 04:39 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 12
Default Rotate more than 90 degrees

Such a simple question, with no helpful links out there.

I want to rotate an image 360/j (it's an animated clock). When you get past 90 degrees the animation either goes backwards using CGAffineTransformMakeRotation or resets to identity using QuartzCore techniques.

Why are the easiest things so hard? Please tell me how to rotate for example 210 degrees (i.e. anything specific over 180). Preferably without the need of a timer to move past the 180 mark.
Everleigh1 is offline   Reply With Quote
Old 01-27-2012, 04:40 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,002
Default

Post your code.
baja_yu is offline   Reply With Quote
Old 01-27-2012, 06:30 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 12
Default

I ended up using this: (sorry I don't know how to post code in the regular format). It works but is anything but elegant...it basically does the first 180 degrees, and then calls another portion to add on the remainder:

Code:
-(void) refresh {
	
	j = 1+ arc4random() % 12;
	degrees = (360/12)*j-.01;
	
	
	rad=(3.14159265*2)/j;
	
	NSLog(@"%i", j);


	hourhand.transform = CGAffineTransformIdentity;
	
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:2];
	[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
	
	if (degrees<=180) hourhand.transform = CGAffineTransformMakeRotation(RADIANS(degrees) );

	else {
		hourhand.transform = CGAffineTransformMakeRotation(RADIANS(179) );
		[self performSelector:@selector(secondhalf) withObject:nil	afterDelay:2];
	}	

	[UIView commitAnimations];
		
}

-(void) secondhalf {
	
//	NSLog(@"%f", degrees-180);

	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:.27*(j-6)];
	[UIView setAnimationCurve:UIViewAnimationCurveLinear];
	
	if(j==12) {
		hourhand.transform = CGAffineTransformMakeRotation(3.13*2);}

		else{hourhand.transform = CGAffineTransformMakeRotation(RADIANS(degrees));}
	
	NSLog(@"%f", RADIANS(degrees));

	
	
}

Last edited by baja_yu; 01-27-2012 at 10:36 PM.
Everleigh1 is offline   Reply With Quote
Reply

Bookmarks

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: 657
22 members and 635 guests
ADY, bandley, BrianSlick, Creativ, dacapo, Dattee, e2applets, gbenna, HDshot, IphoneSdk, iseff, jakerocheleau, jbro, kampftrinker, linkmx, nimesh_158, Reyna, touchcream, ukneeq, yurikus
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 160,619
Threads: 89,833
Posts: 383,490
Top Poster: BrianSlick (7,244)
Welcome to our newest member, yurikus
Powered by vBadvanced CMPS v3.1.0

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