gpt4 book ai didi

ios - UITabController 中的每个选项卡都有许多 View Controller

转载 作者:行者123 更新时间:2023-12-01 20:18:13 26 4
gpt4 key购买 nike

我想用这样的 UI 设计一个应用程序:
enter image description here

在底部,我知道它是 UITabbarController。在每个选项卡中,它有许多 View Controller ,例如 BEAT、TOP、FUN... 每个选项卡都有不同的 View Controller 。
水平滚动时,可以从 BEAT 变为 TOP 到 FUN...
我怎么能这样设计?我应该使用什么 View Controller ?它看起来像 UITabController 中的 UIPageController,但是使用 UIPageController,我不知道如何将底部的点 (.) 替换为顶部的 BEAT、TOP、FUN ...。

谢谢你的帮助。

最佳答案

另一种解决方案是在 View 上添加 UISwipeGesture(Left/Right),并且在滑动操作时,您可以推送或弹出 View Controller 。

在 ViewController.h

@property (retain, nonatomic) UISwipeGestureRecognizer * leftSwipe;
@property (retain, nonatomic) UISwipeGestureRecognizer * rightSwipe;

在 ViewController.m 中
- (void)viewDidLoad
{
[super viewDidLoad];
[self setupSwipeGestures];
}

-(void)setupSwipeGestures
{
_leftSwipe=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(next)];
[_leftSwipe setDirection:UISwipeGestureRecognizerDirectionLeft];

_rightSwipe =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(previous)];
[_rightSwipe setDirection:UISwipeGestureRecognizerDirectionRight];

[self.view addGestureRecognizer:_leftSwipe];
[self.view addGestureRecognizer:_rightSwipe];
}

- (void) previous
{
// perform pop to get previous viewController
// i.e [self.navigationController popViewControllerAnimated:YES];

}

- (void) next
{
// perform push to get next viewController
// i.e [self.navigationController pushViewController:viewController animated:YES];
}

如果您想在每个 Controller 中使用上述代码,那么您可以定义自己的 viewController 并将上述代码粘贴到其中,然后继承您需要上述功能的所有 viewController。

关于ios - UITabController 中的每个选项卡都有许多 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36214277/

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