Change app extension screen rotation in lens c

How to lock from rotating screen, I want my app extension to be in portrait mode only. When I use an extension inside Photos, I can rotate the screen to landscape.

thank

+3


source to share


1 answer


You have a choice:

1- Set landscape and portrait as supported interface orientation in the project, and then for each ViewController you will override the supported interface orientation;

2- Set only portrait mode in project and in ViewController you need it, you can rotate 90 degrees



self.view.transform = CGAffineTransformMakeRotation(M_PI_2);

      

EDIT: you can do this. Set the controller as an observer for keyPath UIDeviceOrientationDidChangeNotification

. Then:

-(void)changedOrientation: (NSNotification *)note
{
    if (note)
    {
        UIDevice *dev = (UIDevice *)note.object;
        if ([dev orientation] == UIInterfaceOrientationLandscapeRight)
        {
            self.view.transform = CGAffineTransformMakeRotation(M_PI_2);
        }
        else if ([dev orientation] == UIInterfaceOrientationPortrait)
        {
            self.view.transform = CGAffineTransformIdentity;
        }
        else if ([dev orientation] == UIInterfaceOrientationPortraitUpsideDown)
        {
            self.view.transform = CGAffineTransformIdentity;
        }
        else if ([dev orientation] == UIInterfaceOrientationLandscapeLeft)
        {
            self.view.transform = CGAffineTransformMakeRotation(-M_PI_2);
        }
    }
}

      

+3


source







All Articles