gpt4 book ai didi

iphone - iPhone 横屏时如何调用另一个 View

转载 作者:行者123 更新时间:2023-11-29 04:37:03 25 4
gpt4 key购买 nike

![第二个 View 是主图库 View ][1]您好,我正在尝试在设备处于横向方向时调用新的 View Controller 。这是一个具有 ScrollView 的图像库,问题是我想在不同的位置显示图像库,但我不知道如何。我正在使用带有 Storyboard的 Xcode 4.3,因此它与我认为的旧版本有点不同。

感谢您的帮助。![这就是没有横向代码的情况下的样子,滚动消失了][2]这就是我调用另一个 View 的原因

当当!我无权发布图片

最佳答案

在 Storyboard中制作风景 View 。在检查器中添加一个标识符,例如 LandscapeView。然后,在你原来的 View Controller 中,导入横向 View 的 View Controller 的头文件:

#import "LandscapeViewController.h" //Change to whatever your file is called

并修改以下方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
LandscapeViewController *landscapeView = [self.storyboard instantiateViewControllerWithIdentifier:@"LandscapeView"]; //change LandscapeViewController to the correct name and change LandscapeView to the correct identifier
landscapeView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; //Or whatever transition you want

[self presentModalViewController:landscapeView animated:NO];
return YES;
}

然后,在横向 View 的 View Controller 中,修改相同的方法如下:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[self dismissModalViewControllerAnimated:NO];
return YES;
}

关于iphone - iPhone 横屏时如何调用另一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10937503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com