开发者

Autorotation distorts a rotated view in iPhone

I use the view-based template to create my app, and return YES in shouldAutorotateToInterfaceOrientation to support auto-rotation. Next, I add a square testView_ object (with default auto-resizing setting), and rotate it at initialization:

- (void)viewDidLoad {
[super viewDidLoad];
    testView_.transform = CGAffineTransformMakeRotation(0.1);
}

Now, whe开发者_StackOverflow社区never I rotate the iPhone, the testView_ will be distorted. What is the reason, and how to correct it? The testView_ width and height are changed after each time I rotate the iPhone, even though it shouldn't be autoresized (and this only happens if the testView_ is rotated initially).


Well, finally my solution is to do

testView_.transform = CGAffineTransformIdentity;

in willRotateToInterfaceOrientation method, then redo

testView_.transform = CGAffineTransformMakeRotation(0.1);

in didRotateFromInterfaceOrientation. This helps solving distortion.

It is more complicated if there are also translation, scaling... involved, but the idea is there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜