이통사 서비스 유지보수를 하며,
아이폰5 해상도 대응으로 고민하던차 좋은글이 있어 옮겨봅니다.
[UIScreen mainScreen]을 많이 활용하시면 될것 같습니다.
혹시나 아이폰5해상도에서도 좌표를 지정해줘야한다면
if ([[UIScreen mainScreen] bounds].size.height == 568.0000) { //2013-01-24 최근 개발하다보니 값이 float 로 리턴되더라고요^^
// 아이폰 4인치 해상도 (아이폰5)
} else {
// 아이폰 3.5인치 해상도
}
이렇게 구분해주시면 됩니다.
참고사이트: http://cafe.naver.com/mcbugi/236038
http://blog.mugunthkumar.com/coding/supporting-the-iphone-5/
iPhone 5 is out and it poses a new challenge to developers, a bigger screen. iOS developers have never been required to support multiple device resolutions in the past. But fret not, Apple has made things easy for us. Follow the four steps below and you are all set.
Step 1:
iPhone 5 requires a new instruction set, the armv7s. Only the latest Xcode, version 4.5 as on writing supports generating armv7s instruction set. Do note that, Xcode 4.5 no longer supports armv6 and deprecates iPhone 3G and older devices. So, build your app using Xcode 4.5
Step 2:
The next step is to add a launch image (Default-568h@2x.png). When you build your project with Xcode 4.5, you will see a warning, “Missing Retina 4 launch image”. Click “Add” to add a default image to your project.
The app now launches in full screen on iPhone 5 without letter boxing on iPhone 5.
Step 3:
However, most of your nib files will still not scale properly. The next step is to check your auto resizing mask of every nib file and ensure that the view inside the nib file automatically sizes based on super view’s height.
The properties that you would use are UIViewAutoresizingFlexibleTopMargin, UIViewAutoresizingFlexibleBottomMargin, UIViewAutoresizingFlexibleHeight. You use the UIViewAutoresizingFlexibleHeight for the top most view so that it autosizes with the main window. You use the UIViewAutoresizingFlexibleTopMargin and/or UIViewAutoresizingFlexibleBottomMargin for subviews.
The UIViewAutoresizingFlexibleTopMargin is used if you want the subview to be “pinned” to the bottom (top margin is flexible) and UIViewAutoresizingFlexibleBottomMargin is used if you want the subview to be “pinned” to the top (bottom margin is flexible).
When you use Cocoa Auto Layout, this step becomes optional. However, Auto Layout is not supported on iOS 5.
Step 4 (optional):
Lastly, any CALayer that you added to the view will have to be manually resized. The code below shows how to do this. I usually use a “patternLayer” to add a pattern to all of my view controllers. You should resize this in the viewWillLayoutSubviews method.
-(void)viewWillLayoutSubviews { self.patternLayer.frame = self.view.bounds; [super viewWillLayoutSubviews]; } |
Step 5 (if you were a messy coder):
If you have hard coded the height of a view to 460 or 480, you might have to change them all using bounds. For example,
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; |
instead of
self.window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; |
That’s it. You are all set!
–
Mugunth
'Scrapbook > 개발 및 프로그래밍' 카테고리의 다른 글
[IOS] 화면 강제 밝기 후 이전 밝기 설정 복원 (1) | 2013.10.11 |
---|---|
ASP.NET Web Service wsdl.exe utility (0) | 2013.09.10 |
[iOS] UIAlertView - didDismissWithButtonIndex 이벤트 문제 (0) | 2012.12.04 |
스마트폰 디바이스별 사이즈(해상도) (4) | 2012.08.22 |
종목발굴 (0) | 2012.02.12 |