objective-c - 带 2 XIB 的旋转人像风景

标签 objective-c uiview landscape portrait

我有 2 个 GUI 和 2 个 Controller 1 称为 landscapeguicontroller,第二个称为 highguicontroller。

现在我通常调用 highguicontroller,当我旋转我的 iPhone 时它​​会检测到它,然后它会显示 landscapeguicontroller: 代码:

    landscapeguicontroller *neu =[[landscapeguicontroller alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:neu animated:YES];     
    [self dismissModalViewControllerAnimated:YES];

问题是动画将新窗口从 iphone 的另一边向上推到窗口中。

在 Landscapeguicontroller 中,我添加了以下几行:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

当我想回到 highguicontroller 时,我调用:

[self dismissModalViewControllerAnimated:YES];

一切正常,但在第二个动画中我看到了正确的“旋转动画”。 你有什么建议吗?

所以简短的问题描述: 1.动画中从高到风景,风景被插入窗口 但是在 2. 从风景到高的动画中,旋​​转看起来像真正的旋转......

我希望 1.animation 看起来像 2.animation

最好的问候 普罗岑内德

最佳答案

为了避免“问题是动画将新窗口从 iphone 的另一边推到窗口中。”,请尝试将 View Controller 的 modalTransitionStyle 属性设置为以下之一,无论您喜欢什么: typedef 枚举 { UIModalTransitionStyleCoverVertical = 0, UIModalTransitionStyleFlipHorizo​​ntal, UIModalTransitionStyleCrossDissolve, } UIModalTransitionStyle;

另外,如果你想避免动画旋转,你可以设置你的 shouldRotate... 方法来禁止其他方向,然后设置为在设备物理改变方向时接收通知,并在适当的方向。有关此示例,请参阅 Apple 的“AlternateViews”示例代码。

通知反射(reflect)了设备的物理方向,无论界面是否允许更改,您都可以收到它们。 (您可以查看 UIApplications 的 statusBarOrientation 属性以了解 UI 的方向)。

关于objective-c - 带 2 XIB 的旋转人像风景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1581563/

相关文章:

ios - 设置 UIView 的角(iOS)

iphone - 我怎样才能像 UIActionSheet 一样从屏幕底部呈现一个 UIView?

ios - 横向和纵向的不同用户界面

iphone - 有没有一种方法可以在 Interface Builder 中实际*视觉设计*双视​​图(横向 + 纵向)?

ios - 如何使用 fetchAssests 按添加日期的顺序获取 PHAssets

objective-c - 如何实现事件自行生成的基于事件的状态机?

ios - 什么是 iOS 7 中的 AppleBasebandManager 框架?

objective-c - 调用 sleep (5);并更新文本字段不起作用

iphone - 如果不在 iphone 应用程序中向下滚动,Scrollview 不会显示其内容的顶部

iphone - 禁用纵向模式