Sooo, I'll give this place a shot...
My wife has commented on my loss of hair the past 2 days on this. I took the project "Which Way Is Up" from iPhone Cookbook and thought about making a learning app that was like Twister/Life/boardgame where you flick the spinner and it spins to whatever slot. I just took the app in the book and modified it.
It's real simple in all you do is move your finger across the UIViewController and the centered UIImageView moves. I store the last 5 touch events in a struct array and get the average distance, time and get speed. I then use that calc to fire off a timer so that when they release their finger, the arrow spins relative to swipe.
Problem is, while touchesMoved is handled, the image seems to be in a context or something, not really updating as you let off your finger, it snaps back to the beginning pos, then moves on my timer.
LOL seems so awefully simple to just update a windows pos on the fly LOL
here's the setup..
- ( void ) loadView
gView = [ [ [ UIImageView alloc ] initWithFrame : CGRectMake ( 0.0, 0.0, rect.size.width / 3 , rect.size.width - 25 ) ] retain ] ;
[ gView setCenter : axis ] ;
[ gView setImage :[ UIImage imageNamed : @"arrow.png" ] ] ;
[ self.view addSubview : gView ] ;
By getting the origin.x and origin.y after the affinetransform, I found the pos updates and I can copy those values to later apply to the UIImage to update it. drawRect is not something Ive done in iPhone and seemed alot of extra work just to update a windows pos, so I figured this would be quick and easy.
things ive tried...
this makes the png move arond the z axis also and zoom in/out etc.
deltaX = gView.frame.size.width ;
deltaY = gView.frame.size.height ;
CGFloat z = gView.layer.zPosition ;
gView.transform = CGAffineTransformMakeRotation ( degreesToRadian(angleDelta) ) ;
CGRect gFrame = gView.frame ;
gFrame.size.width = deltaX ;
gFrame.size.height = deltaY ;
Cant find the proper way to set z Pos on a cgrect frame
gView.layer.frame = gFrame ;
so, I tried this...
turns ok, but its in 3d, i want it to turn flat.
[gView.layer setValue : [NSNumber numberWithFloat:gFrame.origin.x] forKeyPath : @"transform.rotation.x"];
[gView.layer setValue : [NSNumber numberWithFloat:gFrame.origin.y] forKeyPath : @"transform.rotation.y"];
[gView.layer setValue : [NSNumber numberWithFloat:z] forKeyPath : @"transform.rotation.z"];
I cant set the bounds or pos on the frame, not enough xp I guess. But this is something that seems so very simple and the app is multi threaded with many timers, something so very simple stumbling me up is frustrating. Anyone wanna give a brother a hand in figuring this out?