3
我的应用将仅适用于横向方向。我有宽度,高度,x和y变量的主要问题。有没有办法交换所有的宽度,高度,x和y值,所以我不必扭转我的应用程序中的所有坐标? (即(X,Y)具有成为(Y,X)和something.width必须被something.height。)iOS:如何交换横向方向X和Y方向
这里是我的问题的具体例子:
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchPoint = [touch locationInView:unitArea];
if (CGRectContainsPoint(self.view.frame, touchPoint))
{
NSLog(@"released in area");
}
}
这ISN”在景观中工作......它使用了错误的坐标,并且在某些地方,它会输出“在区域中释放”,但不会在视图所在的实际区域中输出。
unitArea bounds are <UIView: 0x6a52420; frame = (20 0; 300 480); transform = [0, -1, 1, 0, 0, 0]; autoresize = RM+BM; layer = <CALayer: 0x6a524a0>>
这显示为我的视图的边界应该是(0 20; 480 300)。
编辑,了解更多信息:
这里是我的(预制)定位方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
,并在项目总结我的“支持的设备取向”只设置为横向。
如果您的应用程序确实处于横向模式,那么iOS将为您处理坐标转换。 – CodaFi 2012-03-20 20:27:07
已更新,提供更多信息。 – Derek 2012-03-20 20:42:02
不应该触摸[locationInView:self.view]? – CodaFi 2012-03-20 20:59:49