Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added the ability to hand over supportededInterfaceOrientations #49

Merged
merged 1 commit into from
Apr 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CWStatusBarNotification/CWStatusBarNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions CWStatusBarNotification/CWStatusBarNotification.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,29 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

@end

@interface CWViewController()

@property (nonatomic, assign) NSInteger _cwViewControllerSupportedInterfaceOrientation;

@end

@implementation CWViewController

- (UIStatusBarStyle)preferredStatusBarStyle
{
return _preferredStatusBarStyle;
}

- (void)setSupportedInterfaceOrientations:(NSInteger)supportedInterfaceOrientations
{
self._cwViewControllerSupportedInterfaceOrientation = supportedInterfaceOrientations;
}

- (NSUInteger)supportedInterfaceOrientations
{
return self._cwViewControllerSupportedInterfaceOrientation;
}

@end

# pragma mark - dispatch after with cancellation
Expand Down Expand Up @@ -182,6 +198,7 @@ - (CWStatusBarNotification *)init
self.notificationIsDismissing = NO;
self.isCustomView = NO;
self.preferredStatusBarStyle = UIStatusBarStyleDefault;
self.supportedInterfaceOrientations = UIInterfaceOrientationMaskAll;

// create tap recognizer
self.tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(notificationTapped:)];
Expand Down Expand Up @@ -351,6 +368,7 @@ - (void)createNotificationWindow
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];
Expand Down