作者leondemon (狗狗)
看板MacDev
标题[问题] Beginning iPhone 3 Development Ch5
时间Sat Sep 11 12:22:32 2010
Beginning iPhone 3 Development (原文书)这本书的第115页(第五章)
提到用两个view来做rotation的转变
不过我不太懂为什麽要这样做...
程式码如下:
在UIViewController底下..
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation duration:(NSTimeInterval)duration {
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
self.view = self.portrait;
self.view.transform=CGAffineTransformIdentity;
self.view.transform=CGAffineTransformMakeRotation(degreesToRadian(0));
self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
...以下省略
}
当侦测到UI方向为Portrait时,就将view改为portrait (a UIView)
但是transform那边以及bounds那边的设定我就不太懂...
为什麽要将bounds设为平躺(landscape)的rect (300是因为扣掉上面的status bar)
然後transform的rotation都设为0度,但从左边的landscape或右边的landscape转
都会依照原本的方向去向左或向右转
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 120.126.38.191
※ 编辑: leondemon 来自: 120.126.38.191 (09/11 12:24)
※ 编辑: leondemon 来自: 120.126.38.191 (09/11 12:25)