开发者

How can I make image always face up?

开发者 https://www.devze.com 2023-02-24 23:37 出处:网络
I have an image that describes a head of a monkey. I want that the head of themonkey always face up. When you turn the device the head of the monkey turns too, but I want that in spite o开发者_运维技巧

I have an image that describes a head of a monkey. I want that the head of the monkey always face up. When you turn the device the head of the monkey turns too, but I want that in spite o开发者_运维技巧f the rotation of the iphone the monkey head dooesn't turn (like a compass).

How can I do this?


If you want to follow the device as it turns you'll have to track with the CLLocationManager.

But if you just want the monkey to be upright as the user transistions from portrait to landscape (and their opposites) then maybe the UIInterfaceOrientation will do the trick:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return YES;
}


  1. to do rotations, with animations, this link might help.
  2. to follow orientation of device it is another story...

probably involving compass using CLLocationManager :) :

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading

or better, using gyroscope


Make sure to look at Apple documentation, there and there Also give a look at Apple sample codes :

How can I make image always face up?

0

精彩评论

暂无评论...
验证码 换一张
取 消