私のアプリは横長のみです。私は幅、高さ、x、yの変数に大きな問題があります。すべての幅、高さ、x、yの値を入れ替える方法があるので、私のアプリですべての座標を逆にする必要はありませんか? (Ieは(x、y)のは(X、Y)になることがあるとsomething.widthがsomething.heightする必要があります。)ここでiOS:横向きのXSとYSを交換するには
は私の問題の具体的な例である:
-(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)これは私のビューの境界として表示されます(0 20; 480 300)。
編集、より多くの情報:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
とプロジェクトの概要に私の「サポートされるデバイスの向きは」唯一の風景に設定されています。ここでは
は私の(既成)配向方法です。
あなたのアプリが本当にランドスケープの場合は、iOSが座標変換を処理します。 – CodaFi
詳細情報を提供するように更新されました。 – Derek
[locationInView:self.view]に触れてはいけませんか? – CodaFi