Skip to content

Commit c595ff3

Browse files
committed
Fixed status bar style and crash when windowPrevious is not exists
1 parent bf71f0d commit c595ff3

6 files changed

Lines changed: 38 additions & 32 deletions

File tree

Demo/LGActionSheetDemo/AppDelegate.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
//
88

99
#import "AppDelegate.h"
10+
#import "TableViewController.h"
1011

1112
@implementation AppDelegate
1213

1314
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
1415
{
15-
self.navigationController = [NavigationController new];
16+
TableViewController *tableViewController = [TableViewController new];
17+
self.navigationController = [[NavigationController alloc] initWithRootViewController:tableViewController];
1618

1719
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
1820
self.window.rootViewController = self.navigationController;

Demo/LGActionSheetDemo/NavigationController.m

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,34 @@
77
//
88

99
#import "NavigationController.h"
10-
#import "TableViewController.h"
1110

1211
@interface NavigationController ()
1312

14-
@property (strong, nonatomic) TableViewController *tableViewController;
15-
1613
@end
1714

1815
@implementation NavigationController
1916

20-
- (id)init
17+
- (void)viewDidLoad
2118
{
22-
self = [super init];
23-
if (self)
24-
{
25-
self.tableViewController = [TableViewController new];
26-
[self setViewControllers:@[self.tableViewController]];
27-
}
28-
return self;
19+
[super viewDidLoad];
20+
21+
self.navigationBar.barTintColor = [UIColor colorWithRed:0.f green:0.5 blue:1.f alpha:1.f];
22+
self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
2923
}
3024

3125
- (BOOL)shouldAutorotate
3226
{
33-
return self.topViewController.shouldAutorotate;
27+
return YES;
28+
}
29+
30+
- (BOOL)prefersStatusBarHidden
31+
{
32+
return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
33+
}
34+
35+
- (UIStatusBarStyle)preferredStatusBarStyle
36+
{
37+
return UIStatusBarStyleLightContent;
3438
}
3539

3640
@end

Demo/Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
source 'https://github.com/CocoaPods/Specs.git'
22

33
platform :ios, '6.0'
4-
inhibit_all_warnings!
54

65
xcodeproj 'LGActionSheetDemo'
76

Demo/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- LGActionSheet (1.0.1)
2+
- LGActionSheet (1.1.1)
33

44
DEPENDENCIES:
55
- LGActionSheet (from `../`)
@@ -9,6 +9,6 @@ EXTERNAL SOURCES:
99
:path: ../
1010

1111
SPEC CHECKSUMS:
12-
LGActionSheet: fe609c9bdd4fd73465966f20b2b388f2c690ef30
12+
LGActionSheet: ec08ab5c3d11815342dd8a327ac47eadc668722e
1313

1414
COCOAPODS: 0.39.0

LGActionSheet.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'LGActionSheet'
4-
s.version = '1.1.0'
4+
s.version = '1.1.1'
55
s.platform = :ios, '6.0'
66
s.license = 'MIT'
77
s.homepage = 'https://github.com/Friend-LGA/LGActionSheet'

LGActionSheet/LGActionSheet.m

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ @interface LGActionSheet () <UITableViewDataSource, UITableViewDelegate, UIGestu
5656
@property (assign, nonatomic, getter=isExists) BOOL exists;
5757

5858
@property (strong, nonatomic) UIWindow *window;
59-
@property (assign, nonatomic) UIWindow *windowPrevious;
60-
@property (assign, nonatomic) UIWindow *windowNotice;
59+
@property (strong, nonatomic) UIWindow *windowPrevious;
60+
@property (strong, nonatomic) UIWindow *windowNotice;
6161

6262
@property (strong, nonatomic) UIView *view;
6363

@@ -179,6 +179,11 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIVi
179179

180180
#endif
181181

182+
- (UIStatusBarStyle)preferredStatusBarStyle
183+
{
184+
return [UIApplication sharedApplication].statusBarStyle;
185+
}
186+
182187
@end
183188

184189
@implementation LGActionSheet
@@ -510,13 +515,17 @@ - (void)windowVisibleChanged:(NSNotification *)notification
510515

511516
UIWindow *window = notification.object;
512517

518+
//NSLog(@"%@", NSStringFromClass([window class]));
519+
520+
if ([window isEqual:_window]) return;
521+
513522
if (notification.name == UIWindowDidBecomeVisibleNotification)
514523
{
515524
if ([window isEqual:_windowPrevious])
516525
{
517526
window.hidden = YES;
518527
}
519-
else if (![window isEqual:_window] && !_windowNotice)
528+
else if (!_windowNotice)
520529
{
521530
_windowNotice = window;
522531

@@ -525,19 +534,11 @@ - (void)windowVisibleChanged:(NSNotification *)notification
525534
}
526535
else if (notification.name == UIWindowDidBecomeHiddenNotification)
527536
{
528-
__weak UIView *view = window.subviews.lastObject;
529-
530-
if (![window isEqual:_window] && [window isEqual:_windowNotice])
537+
if ([window isEqual:_windowNotice])
531538
{
532-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void)
533-
{
534-
if (!view)
535-
{
536-
_windowNotice = nil;
537-
538-
[_window makeKeyAndVisible];
539-
}
540-
});
539+
_windowNotice = nil;
540+
541+
[_window makeKeyAndVisible];
541542
}
542543
}
543544
}

0 commit comments

Comments
 (0)