gpt4 book ai didi

ios - 使用 Storyboard在不同屏幕( View )之间滑动

转载 作者:可可西里 更新时间:2023-11-01 04:59:28 25 4
gpt4 key购买 nike

在我的项目中,我使用了带有 2 个选项卡的 Storyboard。我想创建的是在第一个选项卡中,当您向左滑动时,将显示另一个带有文本的布局,当您再次向左滑动时,另一个布局会显示其他信息(假设我想要 10 个不同的布局模板,但我需要能够更改布局模板中的文本。所以这是我的 Storyboard:

http://i52.tinypic.com/28at3yh.png

在“第一个 View ”中,我需要能够向左滑动并显示带有文本的布局,再次向左滑动并显示(例如)与另一个文本相同的布局,再次向左滑动显示另一个带有文本的布局和很快。所以总共有 10 个布局模板,我需要能够在其中更改代码中的文本。

所以基本上我的目标是与 iPhone/iPad 上的开始窗口相同,您可以在其中滑动应用程序图标所在的屏幕。我怎样才能用相同的动画完成这个?

最佳答案

您正在寻找的是 UIPageControl。可以找到类引用 here并且可以找到一个非常好的教程 here .

如果你想要一个更漂亮的 UIPageControl 和更多可定制的选项,我建议你尝试任何 these . (SMPageControl 是我个人的最爱之一)

根据评论进行编辑:

Here是上面教程中项目的链接。

CustomPagerViewController 中他调用

[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"View1"]];

给出的结果等同于

UIViewController *aViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"View1"];
[self addChildViewController:aViewController];

现在,如果您想添加多个 ViewController,您可以按如下方式进行循环

for(int i = 0; i<yourNumberOfViewControllers; i++) {
YourViewControllerClass *aViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"YourIdentifier"];
[aViewController setSomeProperty:someValue];
[self addChildViewController:aViewController];
}

希望对您有所帮助!

关于ios - 使用 Storyboard在不同屏幕( View )之间滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15122638/

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