在目标c中更改app扩展的屏幕旋转

如何从旋转屏幕锁定,我希望我的应用程序扩展仅在纵向模式下。 当我在照片中使用我的扩展时,我可以将屏幕旋转到横向。

谢谢

你必须选择:

1-在项目中将横向和纵向设置为支持的界面方向,然后对于每个ViewController,您将覆盖支持的界面方向;

2-在项目中仅设置纵向模式,在需要它的ViewController中,可以进行90度旋转

self.view.transform = CGAffineTransformMakeRotation(M_PI_2); 

编辑:所以你可以这样做。 将控制器设置为keyPath UIDeviceOrientationDidChangeNotification观察者。 然后:

 -(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); } } }