CRToast icon indicating copy to clipboard operation
CRToast copied to clipboard

iOS8: notificationWindow incorrect orientation after second run.

Open jtoronto opened this issue 10 years ago • 1 comments

I'm using CRToast in a modally presented, landscape-only view. After the first run, the window is oriented correctly:

Printing description of self->_notificationWindow:
<CRToastWindow: 0x232e3020; baseClass = UIWindow; frame = (0 0; 1024 768); autoresize = W+H;       gestureRecognizers = <NSArray: 0x10ce9890>; layer = <UIWindowLayer: 0x10cd7b30>>

After the view is dismissed, the device is returned to portrait orientation, and then the view is presented a second time, now returning back to landscape orientation, when CRToast fires, the notification window is this:

Printing description of self->_notificationWindow:
<CRToastWindow: 0x232e3020; baseClass = UIWindow; frame = (0 0; 768 1024); autoresize = W+H;      gestureRecognizers = <NSArray: 0x10ce9890>; layer = <UIWindowLayer: 0x10cd7b30>>

The height and the width are flipped. So instead of the notification showing up correctly:

Screenshot 1

It shows up like this:

Screenshot 2

jtoronto avatar Oct 18 '14 14:10 jtoronto

I've temporarily solved this by recreating the notification window in the displayNotification method, and passing in a reference to the view that called for the CRToast notification, and using it's bounds as the window's frame. I know this is a sloppy way to handle this but I have no idea what else to do right now. iOS8 is up to something strange it seems.

`- (void)displayNotification:(CRToast*)notification forParentView:(UIView*)parentView{
UIWindow *notificationWindow = [[CRToastWindow alloc] initWithFrame:[[UIScreen mainScreen]     bounds]];
notificationWindow.backgroundColor = [UIColor clearColor];
notificationWindow.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
notificationWindow.windowLevel = UIWindowLevelStatusBar;
notificationWindow.rootViewController = [CRToastViewController new];
notificationWindow.rootViewController.view.clipsToBounds = YES;
self.notificationWindow = notificationWindow;

if (notification.appearance != nil)
{
    notification.appearance();
}
if (parentView) {
    _notificationWindow.frame = parentView.bounds;
}
...

jtoronto avatar Oct 18 '14 18:10 jtoronto