无法弄清楚iPad横向视图的坐标

时间:2011-08-08 02:40:16

标签: xcode ipad xcode4

成为Objective-C的新手,但我正在尝试使用iPad进行拖动,而我的viewcontroller.m中的以下代码在纵向中可以正常工作,但不适用于横向:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {    
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:mainView.superview];
testViewToMove.center = location;
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}

mainView是使用应用程序创建的默认视图,而testViewToMove是我为踢而制作的UIView。

在横向中,坐标似乎不会翻译。我确信这是显而易见的,但我不明白,这里发生了什么?

我尝试将视图设置为横向,并修改其他一些设置无济于事...我也看到了this,但令我沮丧的是,我无法让它工作。< / p>

1 个答案:

答案 0 :(得分:1)

似乎我只需要在应用上面链接的修补程序后,在第一种方法中将 mainView.superview 更改为 self.view