LeoNatan/LNNotificationsUI

App orientation is locked but the LNNotification rotates

vicky1787 opened this issue · 5 comments

Hello LeoNatan,

I have used this in my Live app and currently facing some issues.

Our entire app is locked to Portrait orientation but the LNNotification gets rotated.

Ive used the pods and hence if I update he Pods then the code will be overwritten by the latest for the changes I make.

Can you provide a function to pass the orientation locked and Type (Landscape / Portrait) while registering this LNNotification View.

I have put this in LNNotificationBannerWindow but i know it will overwrite on the pods update for the fixes you may do to improvise this component.

-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

  • (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
    return UIInterfaceOrientationPortrait;
    }

Can we have a handle outside to lock or access this.

How do you lock your the orientation of your app? Have you set the correct orientation in the app plist?

Another option is to implement - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window in your app delegate, and provide the portrait orientation there.

I am not sure how to solve this. Each window allows its controller stack to determine the allowed orientation. So I could query the main window's allowed orientation, but this is incorrect, as there may be multiple windows alive, each with different supported orientations. Another option is to display notifications only in the orientation the interface was at the time of presentation. I don't like this because the experience suffers for all other applications where rotation is supported.

Hello LeoNatan,

I have implemented the stack in every controller to past the code that will determine what orientation is supported in the view controller.

`

 -(BOOL)shouldAutorotate
 {
   return YES;
 }

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{    //NSLog(@"supported called in red    1");
    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

Also the customised navigation controller have this code.

 - (BOOL)shouldAutorotate {
    return [[self.viewControllers lastObject] shouldAutorotate]; 
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return  [[self.viewControllers lastObject] supportedInterfaceOrientations]; 
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return [[self.viewControllers lastObject] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation]; 
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}

As i have some view controller that support both orientation so the above APPDelegate fix is not good. Please suggest me some solution over this.

I just tested on my demo project.

If the project is defined correctly to only support portrait, notifications do not rotate. Define like so:

screen shot 2016-01-20 at 14 10 34

If your entire app is portrait, you should remove all your functions and just use that.

No my few pic gallery full screen views are supporting both orientation hence I can't use the settings above as u mentioned