相关疑难解决方法(0)

如何在iOS 6中强制UIViewController为Portrait方向

由于ShouldAutorotateToInterfaceOrientation在iOS 6中已弃用并且我使用它来强制特定视图仅限纵向,在iOS 6中执行此操作的正确方法是什么?这仅适用于我的应用的一个区域,所有其他视图都可以旋转.

xcode xamarin.ios ios ios6

85
推荐指数
6
解决办法
10万
查看次数

仅支持iOS 6的一个视图的不同方向

我想在我的应用程序中仅旋转我的一个视图,无论是横向左侧还是横向右侧.我的所有其他视图都处于纵向模式,我已将我的应用程序设置为仅支持纵向模式.在iOS 6中改变方向,我不知道如何做到这一点.我试过下面发布的以下内容.谁能告诉我我做错了什么?谢谢!

-(BOOL)shouldAutorotate {
return YES;
}

-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
} 
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(didRotate:)
                                            name:UIDeviceOrientationDidChangeNotification
                                           object:nil];
return YES;//UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
} 


 -(void)didRotate:(NSNotification *)notification {
 UIDeviceOrientation orientation = [[notification object] orientation];

if (orientation == UIDeviceOrientationLandscapeLeft) {
    [theImage setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
    [self.view setTransform:CGAffineTransformMakeRotation(M_PI / 2.0)];
} else if (orientation == UIDeviceOrientationLandscapeRight) {
    [theImage setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
    [self.view setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
} else if (orientation == …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios

29
推荐指数
2
解决办法
3万
查看次数

覆盖应用程序方向设置

我有一个应用程序,我仅在其目标设置中将方向设置为纵向:

在此处输入图片说明

在一个特定的视图控制器中,我想覆盖此设置,以便在设备旋转时自动布局将更新视图。我试过这些方法没有成功:

override func shouldAutorotate() -> Bool {
    return true
}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.AllButUpsideDown
}
Run Code Online (Sandbox Code Playgroud)

ios autolayout swift

1
推荐指数
1
解决办法
1400
查看次数

标签 统计

ios ×3

xcode ×2

autolayout ×1

ios6 ×1

objective-c ×1

swift ×1

xamarin.ios ×1