viewDidLoad 메서드에서 실제 뷰 크기를 동적으로 결정하는 방법을 많이 검색했습니다.viewDidLoad에서 viewcontroller의 뷰 크기를 동적으로 결정합니다.
가로 모드와 세로 모드 모두에서 iOS6과 iOS7 모두에서 작동하는 것처럼 보이는 접근 방식입니다.
더 나은 솔루션이 있습니까?
- (CGSize)actualSize {
CGFloat widht;
CGFloat height;
// Determin height and widht
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationLandscapeRight || orientation == UIDeviceOrientationLandscapeLeft) {
widht = kHeightSelfView;
height = kWidthSelfView;
} else {
widht = kWidthSelfView;
height = kHeightSelfView;
}
// Determin navigationbar height
CGFloat navigationBarHeight = self.navigationController.navigationBarHidden ? .0f : (MIN(self.navigationController.navigationBar.frame.size.height, self.navigationController.navigationBar.frame.size.width));
// Determin navigationbar height
CGFloat statusbarHeight = [DeviceCompatibility isIOS7] ? (MIN(SharedApplication.statusBarFrame.size.width, SharedApplication.statusBarFrame.size.height)) : .0f;
return CGSizeMake(widht, height - navigationBarHeight - statusbarHeight);
}
정확히는 아니지만 귀하의 코드에서 배웠습니다. 귀하의 의견에 감사드립니다. – flatronka
적어도 투표를 한 후 자유롭게하십시오;) –