gpt4 book ai didi

objective-c - 登录 View 之前的模态视图屏幕

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

我是一名 iOS 开发新手,我有一个关于如何向登录页面添加 View 的问题。目前我有一个登录页面,我想做的是在登录页面可见之前,另一个模态视图应该在它之前,用户必须首先关闭。我如何在 xcode 中添加它?

最佳答案

这里有几个用于呈现 View Controller 的选项。

- (IBAction)goToLoginView:(id)sender
{
//if you are using xibs use this line
UIViewController *controller = [[UIViewController alloc] initWithNibName:@"myXib" bundle:[NSBundle mainBundle]];
//if you are using storyboards use this line
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"myViewControllersID"];

//to present the controller modally use this
[self presentViewController:controller animated:YES completion:nil];
//or if you are pushing to this controller using a navigation controller use this
[self.navigationController pushViewController:controller animated:YES];
}

然后要关闭 View Controller ,请使用以下命令:

- (IBAction)closeMyController
{
//if the view was presented modally close it with this
[self dismissViewControllerAnimated:YES completion:nil];

//and to pop back up the navigation stack
[self.navigationController popToRootViewControllerAnimated:YES];
}

关于objective-c - 登录 View 之前的模态视图屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12322706/

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