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

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

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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-02-2010, 06:00 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Planet Earth
Posts: 4
programingkid is on a distinguished road
Unhappy How to rotate a UIImageView To Face a location??

Hi, im a begginer on iphone dev and im stuck on a problem
Does anyone know how to rotate a UIImageView to face a location???

Eg. if a touch location was X:100 Y:100, make the image rotate and face X:100 Y:100??

Thanx in Advance
programingkid is offline   Reply With Quote
Old 08-02-2010, 09:15 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Are you stuck on actually coding the method, or do you not even have a method?
harrytheshark is offline   Reply With Quote
Old 08-03-2010, 08:19 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Planet Earth
Posts: 4
programingkid is on a distinguished road
Thumbs up

Quote:
Originally Posted by harrytheshark View Post
Are you stuck on actually coding the method, or do you not even have a method?
i havent made the method yet, i dont know how i would make that work
programingkid is offline   Reply With Quote
Old 08-04-2010, 12:39 AM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 21
mgriffin is on a distinguished road
Default

Quote:
Originally Posted by programingkid View Post
i havent made the method yet, i dont know how i would make that work
You first need to know the angle (in radians) that you want to rotate the image by. This is done with atan2.

Quote:
float angle = atan2(yAccel,xAccell);
You then transform the UIImageView:

Quote:
imageView.transform = CGAffineTransformMakeRotation(angle);
HTH
mgriffin is offline   Reply With Quote
Old 08-10-2010, 04:22 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Planet Earth
Posts: 4
programingkid is on a distinguished road
Question

Quote:
Originally Posted by mgriffin View Post
You first need to know the angle (in radians) that you want to rotate the image by. This is done with atan2.



You then transform the UIImageView:



HTH
i tried this but doesn't totally work right. it rotates to the position but doesnt work a full 360 degrees
programingkid is offline   Reply With Quote
Old 08-10-2010, 09:04 AM   #6 (permalink)
Registered Member
 
Ice_2k's Avatar
 
Join Date: Apr 2010
Location: Bucharest, Romania
Posts: 148
Ice_2k is on a distinguished road
Default

I don't wanna be a jerk, but the man told you how to get the angle and then how to use that angle to rotate the image. You just copy/paste his code and then come back here and say it doesn't work all the way? Do some testing, debugging, don't ask for every little step to be fed to you.
Ice_2k is offline   Reply With Quote
Reply

Bookmarks

Tags
image, rotate

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: 328
8 members and 320 guests
alexP, gordo26, headkaze, mistergreen2011, nobstudio, rayjeong, Sloshmonster, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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