Xcode 4.2.1を使用するiPad iOS 5.0.1では、新しい「シングルビュー」iPadプロジェクトを作成します。コントローラでは、追加:回転後、UIView座標はスワップされますが、UIWindowはスワップされません。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void) dumpView: (UIView *) view {
CGRect frame = view.frame ;
CGRect bounds = view.bounds ;
CGPoint center = view.center ;
NSLog(@"view [%@]:%d frame=%@ bounds=%@ center=%@"
, NSStringFromClass(view.class)
, [view hash]
, NSStringFromCGRect(frame)
, NSStringFromCGRect(bounds)
, NSStringFromCGPoint(center)) ;
}
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfaceOrientation {
NSLog(@"INViewController.didRotateFromInterfaceOrientation: %d to %d", fromInterfaceOrientation, self.interfaceOrientation) ;
[self dumpView: self.view] ;
[self dumpView: self.view.superview] ;
}
実行]を、それは、デバイスを回転させ、あなたが取得します:つまり
INViewController.didRotateFromInterfaceOrientation: 2 to 4
view [UIView] bounds={{0, 0}, {1024, 748}} center={394, 512}
view [UIWindow] bounds={{0, 0}, {768, 1024}} center={384, 512}
を、UIViewのは予想通り「風景にスワップ」その座標を有するが、その親UIWindowはまだまた
は、UIViewのサイズが少し間違っているようだ...ポートレートモードであることを主張する:yは20が0であるであるべきである座標...誰でもWH知っていますこの手段で?
意味があります。ありがとうございました。ちなみに、gdbを実際にインタラクティブに使うことができることを私に見せてくれてありがとう: – verec
@rob UIView.frameのrefドキュメントは言う:例外:transformプロパティがIDTでない場合したがって無視する必要があります。あなたはそれについて詳述できますか?回転したビューのフレームをアニメーション化して、オーバーレイとしてスライドさせたいとします。 – tribalvibes
'transform'がアイデンティティでないとき、私は自分のコードで' frame'に依存しません。しかし、 'frame'メソッドは常に' [self convertRect:self.bounds toView:self.superview] 'を返すように見えるので、デバッグするときに便利です。 –