Added the ability to hand over supportededInterfaceOrientations for CWStatusBarNotification. This is optional and the standard value is to support all masks.

This commit is contained in:
Marius Landwehr
2015-04-13 14:07:49 +02:00
parent e9ba7bdeda
commit eef9cc818c
2 changed files with 20 additions and 0 deletions
@@ -22,6 +22,7 @@ typedef void(^CWCompletionBlock)(void);
@interface CWViewController : UIViewController
@property (nonatomic) UIStatusBarStyle preferredStatusBarStyle;
@property (nonatomic, setter=setSupportedInterfaceOrientations:) NSInteger supportedInterfaceOrientations;
@end
@interface CWStatusBarNotification : NSObject
@@ -56,6 +57,7 @@ typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
@property (copy, nonatomic) CWCompletionBlock notificationTappedBlock;
@property (nonatomic) CWNotificationStyle notificationStyle;
@property (nonatomic) NSInteger supportedInterfaceOrientations;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationInStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationOutStyle;
@property (nonatomic) CWNotificationAnimationType notificationAnimationType;
@@ -38,6 +38,12 @@
@end
@interface CWViewController()
@property (nonatomic, assign) NSInteger _cwViewControllerSupportedInterfaceOrientation;
@end
@implementation CWViewController
- (UIStatusBarStyle)preferredStatusBarStyle
@@ -45,6 +51,16 @@
return _preferredStatusBarStyle;
}
- (void)setSupportedInterfaceOrientations:(NSInteger)supportedInterfaceOrientations
{
self._cwViewControllerSupportedInterfaceOrientation = supportedInterfaceOrientations;
}
- (NSUInteger)supportedInterfaceOrientations
{
return self._cwViewControllerSupportedInterfaceOrientation;
}
@end
# pragma mark - dispatch after with cancellation
@@ -182,6 +198,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
self.notificationIsDismissing = NO;
self.isCustomView = NO;
self.preferredStatusBarStyle = UIStatusBarStyleDefault;
self.supportedInterfaceOrientations = UIInterfaceOrientationMaskAll;
// create tap recognizer
self.tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(notificationTapped:)];
@@ -351,6 +368,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
self.notificationWindow.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.notificationWindow.windowLevel = UIWindowLevelStatusBar;
CWViewController *rootViewController = [[CWViewController alloc] init];
[rootViewController setSupportedInterfaceOrientations:self.supportedInterfaceOrientations];
rootViewController.preferredStatusBarStyle = self.preferredStatusBarStyle;
self.notificationWindow.rootViewController = rootViewController;
self.notificationWindow.notificationHeight = [self getNotificationLabelHeight];