gpt4 book ai didi

ios - 在没有 UIScrollView 的情况下使用 UIPageControl

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:09:11 25 4
gpt4 key购买 nike

我目前正在使用滑动手势在 View Controller 之间切换,我想知道我是否可以在不使用 uiscrollview 的情况下在每个 View Controller 上实现一个 uipagecontrol。

下面是我如何从一个 View Controller 转到另一个 View Controller :

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"Home";

UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithTitle:@"\u2699" style:UIBarButtonItemStyleBordered target:self action:@selector(settingsButtonPressed:)];
[settingsButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:24], UITextAttributeFont,nil] forState:UIControlStateNormal];
self.navigationItem.leftBarButtonItem = settingsButton;

UIBarButtonItem *systemAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showMenu)];
self.navigationItem.rightBarButtonItem = systemAction;

UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeRecognizer];
}

- (IBAction)swipeLeft:(UIGestureRecognizer *)sender
{
HomeTwo *homeTwo = [[HomeTwo alloc]initWithNibName:@"HomeTwo" bundle:nil];
homeTwo.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController pushViewController:homeTwo animated:YES];
}

最佳答案

UIPageControl 只是一个 View ,因此您当然可以向每个 View Controller View 添加一个 View ,然后将当前页面设置为适当的值。

关于ios - 在没有 UIScrollView 的情况下使用 UIPageControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18278896/

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