Regarding moving the view, you can do so by updating its frame
property like this.-
view.frame = CGRectMake(view.frame.origin.x + xOffset, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
You may also add and observer
that listens to your view
frame
changes.-
[view addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionOld context:NULL];
Here, you basically are asking for receiving a notification whenever the property frame
of object view
changes. You can handle that notification implementing the following method.-
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if([keyPath isEqualToString:@"frame"]) {
// Change object rotation depending on frame.origin.x
}
}
You'll have to do some maths to calculate rotation based on x
position. Also, I guess rotating the view along its center is a little tricky, maybe you'll find the post below useful.-
http://www.informit.com/blogs/blog.aspx?uk=Ask-Big-Nerd-Ranch-Rotating-an-iPhone-View-Around-a-Point
The thing is, you won't have to worry about wherever you're panning to, as view rotation will just get update according to its position everytime it changes.
Hope it helps :)