标签: uiinterfaceorientation

如何在方向更改时调整UITableView页脚中的UIButton大小

我在UITableView的页脚中使用了两个UIButton(都是单个UIView的子视图).我没有使用UITableViewCell,因为我想要按下按钮,使其看起来像某些iPhone屏幕底部的红色"删除"按钮,例如编辑联系人时.

它的大小和工作正常.但是,该表将根据设备方向更改(横向,纵向等)调整其大小,并且按钮保持其原始宽度.我尝试过使用autoresizing mask但没有任何效果.

它有诀窍,还是更好的方法?

iphone footer uitableview uiinterfaceorientation

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

在iOS8上没有调用willRotateToInterfaceOrientation

我正在我的应用程序中使用VFR PDF查看器库,我在其中呈现它:

ReaderDocument *document = [ReaderDocument withDocumentFilePath:pdfFile password:nil];
ReaderViewController *vc = [[ReaderViewController alloc] initWithReaderDocument:document];
[self.navigationController pushViewController:vc animated:YES];
Run Code Online (Sandbox Code Playgroud)

如果我在iOS7上运行,一切正常.

如果我跑我的iOS8上的应用程序,在ReaderViewController的willRotateToInterfaceOrientation方法不会被调用,所以当设备旋转文档不能正确格式化.

但是,如果我运行自带的iOS8上的库中的演示应用程序,在ReaderViewController的willRotateToInterfaceOrientation不会被调用,这使我相信图书馆是确定的,我做错了什么(或者忽略做某事)在我应用程序.

我对这种行为感到很困惑.为什么不在我的iOS8应用程序中调用rpmRotateToInterfaceOrientation,但它在其他变体下呢?我怎样才能尝试追踪这个?

ipad uiinterfaceorientation vfr-reader ios8

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

在iOS 8中不推荐使用InterfaceOrientation

我没有在我的项目中使用Size类,并继续使用旧方法进行视图控制器方向.我收到了弃用警告,例如当我使用下面的代码时:

    if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
      ...
    }
Run Code Online (Sandbox Code Playgroud)

我搜索了很多但找不到合适的方法来修复它.有什么建议 ?

uikit uiinterfaceorientation autorotate auto-rotation ios8

9
推荐指数
2
解决办法
8043
查看次数

在iPhone上强制更改UIInterfaceOrientation

我想要获得一个iPhone应用程序,它只需要导航控制器堆栈中的每一次推送或弹出来改变方向.

基本上第一个视图是肖像,第二个视图是第三个肖像(是的我知道这不太理想,但那是设计,我必须实现它).

我已经在这里
做了各种建议.... 如何在没有设备自动旋转的情况下检测iPhone上的旋转?
将新视图推送到UINavigationViewController时强制纵向方向
是否有记录的方法来设置iPhone方向?
但没有取得全部成功.

设置链接3.1.2我阅读上面链接的文章似乎表明,如果我的肖像视图推送视图

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight) );
}
,键盘将在需要时以正确的方向显示.

这种方法的问题在于,如果没有状态栏,状态栏转换会很奇怪和丑陋 - 每次更改都会在页面上隐藏阴影.

所以.我错过了什么

1)我认为在3.1.2(或可能更早)中,应该只是通过推动控制器来提供所需的方向,我是错误的吗?

2)是否有另一种方法可以使键盘以正确的方向显示.

3)未记录的API是否可以调用(请不要!)

iphone objective-c uiinterfaceorientation

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

模态视图控制器强制iOS 6中的横向方向

我有一个以纵向模式呈现的UITabBarController.在其中一个选项卡上,我有一个按钮,以模态方式显示UIViewController(一个简单的故事板segue执行操作).

我希望这个模态视图以横向模式显示,但我不能让它自动转动.

我在模态视图控制器中有这个

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Run Code Online (Sandbox Code Playgroud)

我已将landscapeLeft添加到.plist支持的方向(虽然这也允许TabBar旋转,我不想要)

我还将它添加到模态视图的ViewDidLoad中

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
Run Code Online (Sandbox Code Playgroud)

但我不能让它自己旋转.

谢谢

编辑----

似乎应该是自动旋转甚至没有被调用!

此外,我正在尝试检测方向,下面的代码总是显示2,无论方向如何!

if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait) {
        NSLog(@"1");
        self.hostView.frame = CGRectMake(0, 60, 200, 255);
    } else {
        NSLog(@"2");
        self.hostView.frame = CGRectMake(0, 45, 480, 255);
    }
Run Code Online (Sandbox Code Playgroud)

编辑2 ---

我的错.我想我应该提到我正在使用iOS 6.显示器在iOS 5上自动旋转.不推荐使用shouldAutorotateToInterfaceOrientation,所以我需要阅读新方法.

xcode cocoa-touch uiinterfaceorientation modalviewcontroller ios

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

如何在使用故事板时继承Navigation Controller?

我在界面构建器中使用故事板使用Xcode菜单'Editor ... Embed in ... Navigation Controller'.

似乎在iOS 6中你必须将UINavigationController子类化为允许所有方向

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

但是,如何将UINavigationController与故事板应用程序子类化,因为代码中没有对它的引用?

iphone storyboard uinavigationcontroller subclassing uiinterfaceorientation

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

ios 8中的UIWindow框架与Landscape中的ios 7不同

我创建了一个简单的模块,我将子视图添加到UIWindow.在模拟器ios 7(Xcode 5.1.1)中,我打印了self.windows,我得到:

<UIWindow: 0x8db1670; frame = (0 0; 768 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0x8db1a70>; layer = <UIWindowLayer: 0x8db17d0>>
Run Code Online (Sandbox Code Playgroud)

但在ios8(Xcode 6 beta 6)上,我得到:

<UIWindow: 0x794320d0; frame = (0 0; 1024 768); gestureRecognizers = <NSArray: 0x79437a80>; layer = <UIWindowLayer: 0x7943c400>>
Run Code Online (Sandbox Code Playgroud)

问题是:为什么帧属性存在差异?

uiwindow uiinterfaceorientation ios7 xcode6 ios8

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

从枚举类型'enum UIDeviceOrientation'到不同的枚举类型'UIInterfaceOrientation''enum UIInterfaceOrientation的隐式转换

我正在使用Xcode 5.0.2并在尝试编译我的目标C代码时收到以下警告:

从枚举类型'enum UIDeviceOrientation'到不同的枚举类型'UIInterfaceOrientation'(又名'enum UIInterfaceOrientation')的隐式转换

警告在viewController.m中

-(void)youTubeStarted:(NSNotification *)notification{
    // your code here
    NSLog(@"youTubeStarted");
    **[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];**
}

-(void)youTubeFinished:(NSNotification *)notification{
    // your code here
    NSLog(@"youTubeFinished");
}

- (void)youTubeVideoExit:(id)sender {
    **[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];**
}
Run Code Online (Sandbox Code Playgroud)

xcode notifications objective-c uiinterfaceorientation ios

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

iPad方向改变问题

我的iPhone应用程序在支持方向更改时在iPad上运行时会显示一些奇怪的行为.

该应用程序启动时使用视图控制器(为了参数而将其称为视图A)和导航控制器,并且shouldAutorotateToInterfaceOrientation仅为纵向返回YES.在导航控制器上,我按下一个视图控制器(视图B),它也仅为肖像返回YES.然后,我将另一个视图控制器(视图C)推送到支持所有旋转的导航控制器上,并根据要旋转的方向调整屏幕上的项目.

当在iPhone模拟器和设备上运行时,如果您在视图C上旋转到横向,然后点击后退按钮返回到视图B,它会做正确的事情并将视图B切换回纵向模式.(在模拟器中,它甚至可以自动将模拟器旋转回纵向.)

我遇到的问题是,当我在iPad模拟器和设备上执行完全相同的事件序列时,出现的视图B不会旋转回纵向,导航控制器仍然显示视图C的信息.然后,我点击后退按钮,视图保持不变,但导航控制器显示视图B的正常(但所有仍处于横向模式).然后,如果我再次点击后退按钮,视图B会出现在视图B导航栏项目下,最后再次点击后退我会看到带有导航栏A项目的视图A.

如果我在iPad上查看B并开始旋转,那么应该在没有触发的情况下使用NO来触发,直到我达到纵向模式,然后全部恢复正常.

该应用程序使用最新发布的iPhone SDK版本构建,并具有如下构建设置:iPhone模拟器4.0的基本SDK,iPhone的目标设备系列,iPhone OS 3.1.3的iPhone OS部署目标.

有任何想法吗?

iphone ipad uiinterfaceorientation

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

UIDavigationController推送后[UIDevice currentDevice] .orientation == UIDeviceOrientationUnknown

这是一个比任何事情更多的观察,因为我似乎找到了一个解决方法......

当它在一个已被推送到UINavigationController堆栈的控制器中时,下面的代码无法工作.在这种情况下[UIDevice currentDevice].orientation一直回归UIDeviceOrientationUnknown.

-(void)layoutAccordingToOrientation {
    UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
    NSLog(@"layoutAccordingToOrientation/orientation==%i", orientation);
    if (UIInterfaceOrientationIsLandscape(orientation)) {
        :
        _detailToolbar.frame = CGRectMake(0, 660, 1024, 44);
    } else {
        :
        _detailToolbar.frame = CGRectMake(0, 916, 768, 44);
    }
}

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [self layoutAccordingToOrientation];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

以下调用取得:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
Run Code Online (Sandbox Code Playgroud)

要解决这个UIDeviceOrientationUnknown问题,我现在使用以下代码:

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation)) {
    etc.
} else {
    etc.
}
Run Code Online (Sandbox Code Playgroud)

......每次都有效.

尽管如此,我仍然不明白为什么第一个变体在推送视图控制器的上下文中不起作用.想法有人吗?这只是一个错误吗?

iphone uinavigationcontroller uiinterfaceorientation uideviceorientation

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