Cor*_*oyd 2 iphone cocoa-touch core-graphics
我认为标题非常具有描述性:
我在一个视图上执行所有这三个操作,结果是屏幕左侧有20个像素的空白区域(如果持有iPhone是landscapeLeft).
我尝试通过执行CGAffineTransFormTranslate来修复它(变换,-20,0)
这只是"滑动"空白下面的视图.
这开始感觉像一个bug,其他人都有这个问题?
澄清一点,我不是在转动任何观点.我正在感知设备的方向:
[[UIDevice currentDevice] orientation]
Run Code Online (Sandbox Code Playgroud)
如果设备(不是界面)处于横向,那么:
[navigationController presentModalViewController:NewView animated:NO]
Run Code Online (Sandbox Code Playgroud)
转换是在显示之前将我的视图(在IB中创建)旋转到横向.
我的转换代码:
CGRect myFrame = CGRectMake(0, 0, 480, 320);
CGAffineTransform transform = [[self.myPeriodicTableViewController view] transform];
transform = CGAffineTransformRotate(transform, degreesToRadians(rotationDirection * 90));
transform = CGAffineTransformTranslate(transform, -20, 0);
[[self.myPeriodicTableViewController view] setFrame: myFrame];
CGPoint center = CGPointMake(myFrame.size.height/2.0, myFrame.size.width/2.0);
[[self.myPeriodicTableViewController view] setTransform: transform];
[[self.myPeriodicTableViewController view] setCenter: center];
Run Code Online (Sandbox Code Playgroud)
我想你可能需要重新进入你的中心:
// Set the center point of the view to the center point of the window's content area.
self.view.center = CGPointMake(160.0, 240.0);
Run Code Online (Sandbox Code Playgroud)
这是我用于横向视图的整个init方法,并且没有问题.只需确保将笔尖设置为正确的尺寸.
// Implement viewDidLoad to do additional setup after loading the view.
- (void)viewDidLoad {
[super viewDidLoad];
// Rotate to landscape
self.view.frame = CGRectMake(0, 0, 480.0, 320.0);
if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
CGAffineTransform transform = self.view.transform;
// Set the center point of the view to the center point of the window's content area.
self.view.center = CGPointMake(160.0, 240.0);
// Rotate the view 90 degrees around its new center point.
transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
self.view.transform = transform;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15554 次 |
| 最近记录: |