Skip to content

Commit d35c677

Browse files
1 Correct the menu width when the orientation change.
2 Fix iOS 7.0 problem ( 7.0's offset should be 0 but current is 20).
1 parent e5f8bac commit d35c677

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

DropdownMenu/DropdownMenuController.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ - (void)iOS6_hideMenuCompleted {
192192

193193

194194
-(CGFloat)offset {
195+
return ([self isLandscape] && !SYSTEM_VERSION_LESS_THAN(@"8.0")) ? 20.0f : 0.0f;
196+
}
197+
198+
-(bool)isLandscape {
195199
UIInterfaceOrientation interfaceOrientation;
196200

197201
// Check if we are running an iOS version that support `interfaceOrientation`
@@ -202,9 +206,15 @@ -(CGFloat)offset {
202206
interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
203207
}
204208

205-
return UIInterfaceOrientationIsLandscape(interfaceOrientation) ? 20.0f : 0.0f;
209+
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
206210
}
207211

212+
-(CGFloat)correctWidth {
213+
CGRect screenRect = [[UIScreen mainScreen] bounds];
214+
CGFloat max = MAX(screenRect.size.width, screenRect.size.height);
215+
CGFloat min = MIN(screenRect.size.width, screenRect.size.height);
216+
return [self isLandscape] ? max : min;
217+
}
208218

209219
- (void) drawOpenLayer {
210220
[openMenuShape removeFromSuperlayer];
@@ -281,6 +291,7 @@ -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOr
281291

282292
CGRect menuFrame = self.menu.frame;
283293
menuFrame.origin.y = self.menubar.frame.size.height - self.offset;
294+
menuFrame.size.width = [self correctWidth];
284295
self.menu.frame = menuFrame;
285296

286297
[self drawClosedLayer];

0 commit comments

Comments
 (0)