标签: uiinterfaceorientation

在ios上旋转时更改子视图

我需要一个视图控制器(在ipad上)共享两种模式,一种是纵向模式,另一种是横向模式.实际上,我非常想模仿UISplitViewController的功能,但我希望能够使用不作为顶级视图控制器.除了HIG指南之外,我有一个普遍的问题,我认为任何在方向之间切换视图的人都会遇到.

1)为了提供视图之间的平滑过渡,我想在willRotateToInterfaceOrientation:duration中调用我的视图更改(和动画),而不是didRotateToInterfaceOrientation方法.问题是,在这个阶段,视图框架和边界尚未更改为新的视图框架和边界,因此您最终必须手动设置框架,如:

subview.frame = CGRectMake(0,0,320,768);
Run Code Online (Sandbox Code Playgroud)

也许是:而不是更好的东西:

subview.frame = CGRectMake(0,0,320, self.view.frame.height);
Run Code Online (Sandbox Code Playgroud)

2)此外,即使您尝试这样的恶作剧,如果视图自动调整其子视图,您仍然无处可去.如果禁用子视图的自动调整,那么这样的东西甚至不再起作用了:

subview.frame = self.view.frame; //because then you'd have to always specify the exact rect.
Run Code Online (Sandbox Code Playgroud)

有没有人有任何见解可以提供这个?

谢谢!

rotation uiinterfaceorientation ios

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

启动应用并保持横向模式

如何在横向模式下启动应用程序,并保持屏幕旋转方式?

cocoa-touch landscape objective-c uiinterfaceorientation ios

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

如何在仅在iOS-6中支持横向定位的应用中使用UIImagePickerController?

我正在开发一个仅支持横向定位的应用程序.它使用a UIImagePickerController从库中选择图像和/或视频.应用程序在iOS-5或之前运行良好但在我尝试呈现图像选择器控制器时它会崩溃.它在崩溃后给出以下消息:

*由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'

landscape uiimagepickercontroller uiinterfaceorientation ios6

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

仅限肖像模式 - iOS

我有一个应用程序,仅用于纵向方向.但是,我不知道如何限制只使用纵向模式,一旦用户颠倒或空间模式,我不希望我的屏幕orinetation相应地改变.

有什么想法怎么做?

uiinterfaceorientation ios ios5 ios6

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

UIDeviceOrientationDidChangeNotification适用于iDevice 4及以下但不适用于iDevice 5

花花公子!

需要一些紧急的见解.我的问题是,即使iPhone 4/4S和iPod 4上的测试正常旋转,此代码也是如此:

- (void)initNotifications
{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"setFreeOrientation" object:nil];

    [[UIDevice currentDevice]beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter]addObserver:self
                                            selector:@selector(didRotate:)
                                                name:UIDeviceOrientationDidChangeNotification
                                              object:Nil];
}

-(void)didRotate:(NSNotification*)notification
{
    [super rotateTopBars];
    [super rotateOptionsBar];
    [self rotateControlBar];
    [self rotatePlayer];
    [super rotateShareLayer];
}
Run Code Online (Sandbox Code Playgroud)

但我正在测试iPod 5并且它不起作用.尝试了一些东西但直到现在都没有运气.

干杯.

iphone ipod-touch uiinterfaceorientation ios6

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

iOS 6 Tab Bar App:shouldAutorotate无效

我正在使用iOS 6和Xcode 4.5在Storyboard中使用标签栏和一些导航视图控制器开发应用程序

通常应用程序应支持所有界面方向,但我有两个视图,只应支持纵向模式.

所以我将以下代码添加到视图控制器:

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud)

在我在iOS 6上开发的没有故事板和导航视图控制器的其他应用程序上它可以工作,但她不是!:/

我希望有人可以提供帮助,因为我找到了其他一些无用的帖子......

来自德国的问候

Laurenz

编辑:

我也尝试过 - 不行!:

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;

} 
Run Code Online (Sandbox Code Playgroud)

uitabbarcontroller uiinterfaceorientation ios6

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

iOS - 将特定的UIViewController锁定到特定方向

我的应用程序支持所有4方向,我有一个UIViewController这是LandscapeRight.我正在使用UINavigationController推动它UIViewController,我希望它UIViewController只是在UIInterfaceOrientationLandscapeRight,但当我旋转手机时,它切换回其他方向.

-(BOOL)shouldAutorotate{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationLandscapeRight;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeRight;
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiviewcontroller uiinterfaceorientation ios

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

iOS 9 界面旋转结束时回调?

我还没有看到这个问题的明确答案,围绕 iOS 8 的变化有很多噪音,但我想在 iOS 9 上解决这个问题:

\n\n

界面方向更改结束后获取回调的正确方法是什么?

\n\n

从 iOS 9 开始,didRotateFromInterfaceOrientation:它已被弃用,官方文档告诉我们改用它viewWillTransitionToSize:withTransitionCoordinator。这为我们(通过transitionCoordinator)提供了一种沿着过渡进行动画处理的方法和一个完成块,但没有对过渡的真实 \xe2\x80\x98end\xe2\x80\x99 进行直接回调。

\n\n

另一种方法是transitionCoordinatornotifyWhenInteractionEndsUsingBlock:但这似乎报告了过渡的交互部分的结束,而不是整个事情。

\n\n

那么, \xe2\x80\x9cofficial\xe2\x80\x9d 的方法是执行此操作animateAlongsideTransition:completion,并简单地忽略动画选项吗?

\n\n

我意识到我们仍然可以使用旧的didRotateFromInterfaceOrientation:,但它\xe2\x80\x99s 总是更好地尽可能现代化。

\n

transition uiviewcontroller uiview uiinterfaceorientation ios9

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

无法强制应用程序在iOS9中仅限纵向

我需要我的应用程序才支持纵向方向.但升级到iOS9后,方向设置似乎没有效果.我已经完成了这个答案,这是我的应用程序设置:

方向设置

但仍然应用程序进入景观.我究竟做错了什么?

uiinterfaceorientation ios

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

错误[NSISLinearExpression orientationChanged:]:发送到实例的无法识别的选择器

当我改变方向时,我在app中出现了这个错误,我第一次得到它,我以前从未见过这种类型的错误,

我已经搜索了很多关于这个错误,但我没有找到解决这个问题,

在我的应用程序中,我已经编写了NSNotification以进行方向更改

Scroller.m

-(id)initWithFrame:(CGRect)frame {
    self=[super initWithFrame:frame];
    if (self) {
        // Initialization code

        scrollView=[UIScrollView new];
        pageControl=[UIPageControl new];
        scrollView.delegate=self;

        scrollView.pagingEnabled=YES;
       scrollView.showsHorizontalScrollIndicator=NO;
        scrollView.showsVerticalScrollIndicator=NO;

        scrollView.translatesAutoresizingMaskIntoConstraints=NO;
        pageControl.translatesAutoresizingMaskIntoConstraints=NO;


        scrollView.backgroundColor=[UIColor clearColor];
        pageControl.backgroundColor=[UIColor darkGrayColor];
        [pageControl addTarget:self action:@selector(changePage) forControlEvents:UIControlEventValueChanged];

        [self addSubview:scrollView];
        [self addSubview:pageControl];
        self.pageControl.currentPage = 0;
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
        [self setData];

    }
    return self;
}

-(void)orientationChanged{
 [self updateFrame];

}
-(void)updateFrame{

    [self layoutIfNeeded];
    CGRect mainFrame=scrollView.frame;
    CGRect frame;
.
.
.
.
    // COdes for Updating Frame
}
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

-[NSISLinearExpression orientationChanged:]: unrecognized selector sent to instance …

iphone objective-c uiinterfaceorientation ios ios7

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