私は最も単純なことを達成しようとしています-デバイスの向きに関係なく、アプリケーションフレーム(つまり、画面からステータスバーの高さを引いたもの)を埋める(そして正確にフィットする)UIScrollViewを作成します。
ただし、これは非常に困難であることが証明されています。スクロールビューは、横向きビューで正しくサイズ変更することに抵抗があるようです。理由はわかりません。
アプリケーションフレームの使用を忘れて、ステータスバーの高さを無視して画面全体に表示しようと決心しましたが、それでも不可能でした。
私が使用しているアプローチを以下に示します。誰かがこれを正しく行う方法を示すのに十分親切ですか?特にiPhone/iPadの画面全体を埋めようとすると、オブジェクトのサイズを正しく設定する際に恒久的に問題が発生するようです。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
CGFloat viewedWidth, viewedHeight;
const CGSize dim = [UIScreen mainScreen].bounds.size;
if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)) {
viewedWidth = dim.width;
viewedHeight = dim.height;
} else {
viewedWidth = dim.height;
viewedHeight = dim.width;
}
[self.scrollView setFrame:CGRectMake(0.0f, 0.0f, viewedWidth, viewedHeight)];
}
-(void)viewDidLoad {
[self.view setFrame:[UIScreen mainScreen].bounds];
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,1,1)];
[self.scrollView setDelegate:self];
[self.view addSubview:self.scrollView];
[self.scrollView setContentSize:sizeManager.canvasSize];
[self didRotateFromInterfaceOrientation:UIInterfaceOrientationPortrait]; // NOTE: orientation passed is not used, dummy
}
あなたのアドバイスは大歓迎です、どうもありがとう。