# \[SDK\] UIInterfaceOrientationMask

**URL:** <https://the.fmsoup.org/t/sdk-uiinterfaceorientationmask/3273>\
**Category:** Questions\
**Created:** [December 18, 2022, 11:29pm UTC](https://the.fmsoup.org/t/sdk-uiinterfaceorientationmask/3273 "2022-12-18T23:29:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfpx](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sfpx](https://the.fmsoup.org/u/sfpx)\
**Post date:** [December 18, 2022, 11:29pm UTC](https://the.fmsoup.org/t/sdk-uiinterfaceorientationmask/3273/1 "2022-12-18T23:29:38Z")

</div>

**In MyAppDelegate.m**

```auto
@interface MyAppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
{
    NSInteger skipforeground;
    BOOL allowLandscape;
    NSInteger NoCheck;
}

- (UIInterfaceOrientationMask)application:(UIApplication *) application
  supportedInterfaceOrientationsForWindow:(UIWindow *) window {
    
    if (self->allowLandscape==true) {
        NSLog(@"rotation yes !");
        return UIInterfaceOrientationMaskAll;
    } else
    {
        return UIInterfaceOrientationMaskPortrait;
    };
    
}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{

//Called when a notification is delivered to a foreground app.
     
    NSString *Param=notification.request.content.userInfo[@"scriptParam"];
    if ([Param isEqual:@"TurnOffRotation"]) {
        self->allowLandscape=false;
    }

} else if ([Param isEqual:@"TurnOnRotation"]) {
       self->allowLandscape=true;    
    }

```

**In Filemaker**

```auto
Configure Local Notification [Action: Queue ; Name: "RunFunction" ; Script: “EmptyScript” ; Parameter: "TurnOnRotation"; Delay: 0] 

```

The code above was used to unlock or lock landscape orientation depending on the layout .

It stopped working for some reason.

The condition is met and I see "rotation yes !" in the log but the screen won't rotate.  
If I change the condition for an always true condition like "2\>1" the screen will rotate.  
As soon as I reference self-\>allowLandscape in supportedInterfaceOrientationsForWindow the code is executed but the screen does not rotate.

Anyone knows how to fix it ?

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [December 19, 2022, 12:31am UTC](https://the.fmsoup.org/t/sdk-uiinterfaceorientationmask/3273/2 "2022-12-19T00:31:09Z")

</div>

Hi @sfpx, interesting problem. I'll tag @bhamm. He's got a lot of experience with Swift and FileMaker.

---

<div class="post-metadata">

**Author:** ![planteg](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/planteg/32/627_2.png) [@planteg](https://the.fmsoup.org/u/planteg)\
**Post date:** [December 19, 2022, 4:28am UTC](https://the.fmsoup.org/t/sdk-uiinterfaceorientationmask/3273/3 "2022-12-19T04:28:53Z")

</div>

Welcome to Thesoup @sfpx !

---

<div class="post-metadata">

**Author:** ![sfpx](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sfpx](https://the.fmsoup.org/u/sfpx)\
**Post date:** [December 22, 2022, 5:29pm UTC](https://the.fmsoup.org/t/sdk-uiinterfaceorientationmask/3273/4 "2022-12-22T17:29:52Z")

</div>

Thanks.  
Anyone has any idea what could cause this ?  
This is so strange to me.

---

<div class="post-metadata">

**Author:** ![sfpx](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sfpx](https://the.fmsoup.org/u/sfpx)\
**Post date:** [April 11, 2023, 3:46pm UTC](https://the.fmsoup.org/t/sdk-uiinterfaceorientationmask/3273/5 "2023-04-11T15:46:20Z")

</div>

Finally was able to get it to work (IOS 16+ only) by adding this

```auto
 if (@available(iOS 16.0, *)) {
            [UIApplication sharedApplication].keyWindow.rootViewController.setNeedsUpdateOfSupportedInterfaceOrientations;
        }

```

after each time I change allowLandscape

For example

```auto
...
else if ([Param isEqual:@"TurnOnRotation"]) {
       self->allowLandscape=1;
 if (@available(iOS 16.0, *)) {
            [UIApplication sharedApplication].keyWindow.rootViewController.setNeedsUpdateOfSupportedInterfaceOrientations;
        };
}
...

```
