1 getting the iOS device screen information
Cgsize iosdevicescreensize = [UIScreen mainscreen].bounds.size; *s = [NSString stringWithFormat:@ "%.0f x%.0f", Iosdevicescreensize.width, Iosdevicescreensize.height];
get device information to determine whether it is ipone-judging the horizontal screen or vertical screen-judging the device model
Property Userinterfaceidiom is an enumeration type
if([uidevice Currentdevice].userinterfaceidiom = =Uiuserinterfaceidiomphone) { if(Iosdevicescreensize.height > Iosdevicescreensize.width) {//Vertical Screen Condition if(Iosdevicescreensize.height = =568) {//iPhone 5/5s/5c (IPod touch 5) deviceNSLog (@"iPhone 5/5s/5c (IPod touch 5) device"); } Else if(Iosdevicescreensize.height = =667) {//IPhone 6NSLog (@"IPhone 6 Devices"); } Else if(Iosdevicescreensize.height = =736) {//IPhone 6 PlusNSLog (@"IPhone 6 Plus device"); } Else{//iphone4s and other equipmentNSLog (@"iphone4s and other equipment"); } } if(Iosdevicescreensize.width > Iosdevicescreensize.height) {//Horizontal Screen condition if(Iosdevicescreensize.width = =568) {//iPhone 5/5s/5c (IPod touch 5) deviceNSLog (@"iPhone 5/5s/5c (IPod touch 5) device"); } Else if(Iosdevicescreensize.width = =667) {//IPhone 6NSLog (@"IPhone 6 Devices"); } Else if(Iosdevicescreensize.width = =736) {//IPhone 6 PlusNSLog (@"IPhone 6 Plus device"); } Else{//iphone4s and other equipmentNSLog (@"iphone4s and other equipment"); } } }}
2 vertical screen in the status bar 20 points, navigation bar 44 points, Tab bar 49 points. The general content view picture size can be designed.
1) Traditional layout: In order to ensure that both the vertical screen and the horizontal screen can display the control, you need to set the distance between the control and the screen is absolute distance. The Autosizing property setting in view.
Simulator Rotation screen is COMMAND + LEFT arrow
2) AutoLayout layout: Constraint defines the relationship between controls and views to only address small differences in the interface
Snapping: Creating Center and alignment constraints
Pin: Create distance and position-dependent constraints constrain to margins constraints on edges, typically unchecked
Modified by the constraint's property inspector
3 Size class with iOS 8 multi-screen adaptation
Compact <any<regular Normal
Wcompact|hcompact for the horizontal screen of all iphone except 5.5 inch iphone
Wregular|hcompact for 5.5 "iphone horizontal screen case
Wcompact|hany wcompact|hregular for vertical screen condition
Preview feature: Auxiliary editor-preview-main.storyboard Click + to add a preview device
Quick fix for layout problem due to vertical screen and horizontal screen switching: Add Missing constrains
4 screen Scrolling view Uitextview and Uiscrollview adaptation issues to be combined with code to solve
Frame properties: View frame size
Contentsize Properties: Content View Size Cgsize type
Contentinset properties: Add a border around the content view, typically to place the toolbar, including the top bottom left right four components
Contentoffset property: The offset of the content view and the screen scrolling view coordinate origin Cgpoint type setting method:-setcontentoffset:animated:
*********
Bounds (cgrect type): Frame and Origin component, the types of these two components are cgsize and Cgpoint
*********
End layout problem The general process is to use size class-to add constraints once-and then fine-tune iterations
The view layout will be callback-(void) Viewdidlayoutsubviews method can set the view
5 Using Asset catalog to manage pictures: devices of different resolutions use different pictures
Open image.xassets-Click + Select menu-Set device-Open Picture folder drag and drop picture-use in code or Interfacebuilder
1* is different display of the 4s retina2* is the 5/5s/5c is 6/6p
iOS Development Guide Chapter fourth IOS8 multi-resolution screen adaptation learning