Skip to content
This repository was archived by the owner on Apr 15, 2022. It is now read-only.

Commit bdd7fe5

Browse files
committed
Fix bugs
1. Fix rotation bugs. It will dismiss frequently using device orientation rather than interface orientation. 2. Fix divider display issue. Redraw the UI after next/previous page button clicked.
1 parent 815a730 commit bdd7fe5

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

MenuPopOverView/MenuPopOverView.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ @interface MenuPopOverView()
3737
@property (nonatomic) CGRect boxFrame;
3838
@property (nonatomic) int pageIndex;
3939

40+
@property (nonatomic) UIInterfaceOrientation lastInterfaceOrientation;
41+
4042
- (void)didTapLeftArrowButton:(UIButton *)sender;
4143
- (void)didTapRightArrowButton:(UIButton *)sender;
4244

@@ -71,6 +73,7 @@ - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view withStrings:(N
7173
// listen on device rotation
7274
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
7375
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onDeviceRotation:) name:UIDeviceOrientationDidChangeNotification object:nil];
76+
_lastInterfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
7477

7578
UIView *buttonContainer = [[UIView alloc] initWithFrame:CGRectZero];
7679
buttonContainer.backgroundColor = [UIColor clearColor];
@@ -454,6 +457,8 @@ - (void)didTapLeftArrowButton:(UIButton *)sender {
454457
[UIView animateWithDuration:0.25 animations:^{
455458
self.contentView.frame = contentFrame;
456459
}];
460+
461+
[self setNeedsDisplay];
457462
}
458463

459464
- (void)didTapRightArrowButton:(UIButton *)sender {
@@ -477,6 +482,8 @@ - (void)didTapRightArrowButton:(UIButton *)sender {
477482
[UIView animateWithDuration:0.25 animations:^{
478483
self.contentView.frame = contentFrame;
479484
}];
485+
486+
[self setNeedsDisplay];
480487
}
481488

482489
- (UIButton *)getControlButton:(BOOL)rightArrow {
@@ -511,7 +518,14 @@ - (void)resetBackgroundColor:(UIButton *)sender {
511518

512519
#pragma mark - rotation
513520
- (void)onDeviceRotation:(NSNotification *)noti {
514-
NSLog(@"device rotation detected");
521+
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
522+
523+
if (_lastInterfaceOrientation == orientation ||
524+
(UIInterfaceOrientationIsPortrait(_lastInterfaceOrientation) &&
525+
UIInterfaceOrientationIsPortrait(orientation))) {
526+
return;
527+
}
528+
515529
[self dismiss:NO];
516530
}
517531

0 commit comments

Comments
 (0)