gpt4 book ai didi

ios - 下滑模态导航

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

我有一个包含按钮的UIViewController。单击按钮时,它会作为模式(向上滑动过渡)转换为具有两个选项卡项的TabViewController

在两个选项卡项上,我都有一个“关闭”按钮,我想在该按钮上切换回上面提到的 UIViewController,但采用向下滑动的过渡。

我该怎么做?

最佳答案

假设,您的按钮关闭目标为 dismissMe

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(0, 0, 100, 75);
button.titleLabel.text = @"Close";
[button setBackgroundColor:[UIColor greenColor]];
button.center = self.view.center;
[button addTarget:self action:@selector(dismissMe) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

然后请将以下代码添加到目标方法中。

-(void)dismissMe {
[self dismissViewControllerAnimated:YES completion:nil];
}

也可以用这个代替

[self.parentViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];

关于ios - 下滑模态导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20585335/

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