2
我有一些代碼,看起來像這樣在我GLKViewController子類:改變座標方位的iOS
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch * touch = [touches anyObject];
CGPoint point = [touch locationInView:self.view];
NSLog(@"touch has begun!: %f %f",point.x,point.y);
float xw = [self.view bounds].size.width;
float yw = [self.view bounds].size.height;
NSLog(@"touch -- %f %f", point.x/xw, point.y/yw);
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationLandscapeRight == toInterfaceOrientation;
}
而且我已經在「iPhone/iPod的部署設置我唯一支持的設備定位爲「景觀權」信息」。
通過使用上面的代碼運行測試,看起來好像左上角是(0,0)。但是,我有另一個類似於(0,0)點位於左下角的測試項目。
究竟是什麼決定了座標系的方向?如果我想讓我的(0,0)點成爲左下角而不是左上角,那麼我該怎麼做?
我可能會誤解另一個項目。我只是害怕我可能無意中做了一些事情,而當我處於這個過程中時,方向可能會翻轉。保證它總是在左上角對我來說足夠好。 – math4tots