@@ -65,12 +65,6 @@ -(void)keyboardWillChangeFrame:(NSNotification*)notification {
65
65
CGFloat bottom = CGRectGetHeight ([[info objectForKey: UIKeyboardFrameEndUserInfoKey] CGRectValue ]);
66
66
CGFloat scale = [UIScreen mainScreen ].scale ;
67
67
68
- // scale == 3 => screen is 1242 * 2208 => we have to perform down-sampling to obtain the real length
69
- // 0.8696 = 1920 / 2208, the vertical down-sampling ratio
70
- if (scale == 3 ) {
71
- bottom = bottom * 0.8696 ;
72
- }
73
-
74
68
viewInsets.bottom = bottom * scale;
75
69
padding.bottom = 0 ;
76
70
@@ -100,14 +94,18 @@ viewMetrics IOSGetViewportPadding()
100
94
viewMetrics metrics;
101
95
viewPadding insets = [[UIWidgetsViewController sharedInstance ] viewInsets ];
102
96
viewPadding padding = [[UIWidgetsViewController sharedInstance ] padding ];
103
- metrics.insets_bottom = insets.bottom ;
104
- metrics.insets_top = insets.top ;
105
- metrics.insets_left = insets.left ;
106
- metrics.insets_right = insets.right ;
107
- metrics.padding_bottom = padding.bottom ;
108
- metrics.padding_top = padding.top ;
109
- metrics.padding_left = padding.left ;
110
- metrics.padding_right = padding.right ;
97
+
98
+ CGFloat scale = [UIScreen mainScreen ].scale ;
99
+ BOOL needDownsample = scale == 3 ;
100
+
101
+ metrics.insets_bottom = needDownsample ? insets.bottom * 0.8696 : insets.bottom ;
102
+ metrics.insets_top = needDownsample ? insets.top * 0.8696 : insets.top ;
103
+ metrics.insets_left = needDownsample ? insets.left * 0.8696 : insets.left ;
104
+ metrics.insets_right = needDownsample ? insets.right * 0.8696 : insets.right ;
105
+ metrics.padding_bottom = needDownsample ? padding.bottom * 0.8696 : padding.bottom ;
106
+ metrics.padding_top = needDownsample ? padding.top * 0.8696 : padding.top ;
107
+ metrics.padding_left = needDownsample ? padding.left * 0.8696 : padding.left ;
108
+ metrics.padding_right = needDownsample ? padding.right * 0.8696 : padding.right ;
111
109
112
110
return metrics;
113
111
}
0 commit comments