我见过其他人也提出过这个问题,但大多数回复都不适用于最新的 3.0 版 iPhone 操作系统。不管怎样,我想知道如何在没有来自加速度计的任何输入的情况下以编程方式旋转 UIView。到目前为止我找到的代码:
CGAffineTransform transform = CGAffineTransformMakeRotation(3.14159/2);
view.transform = transform;
CGRect contentRect = CGRectMake(-80, 80, 480, 320);
view.bounds = contentRect;
但是,这不适用于 UIView(在我的测试中)。我是否必须对 AppDelegate 执行某些操作才能使此/其他代码正常运行,或者是否有更好的方法来执行相同的操作?
感谢您的帮助!
最佳答案
这对我有用
CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI_2);
self.view.transform = transform;
// Repositions and resizes the view.
CGRect contentRect = CGRectMake(0,0, 480, 320);
self.view.bounds = contentRect;
关于iphone - 在 Cocoa Touch 中旋转 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1350233/