gpt4 book ai didi

ios - 模态窗口没有被关闭

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

我有两个以编程方式创建的按钮,您可以在我的 viewDidLoad 方法中看到。在模态窗口上,我有一个通过委托(delegate)调用 cancelSearch 方法的按钮。当我在我的 cancelSearch 方法上放置一个断点时,它会被命中,所以我知道我的委托(delegate)设置正确,但即使它调用了这一行 [self dismissViewControllerAnimated:YES completion:nil];它实际上并没有关闭模态窗口。

下面的代码全部来自我的主 Controller View 。

- (void)viewDidLoad
{
[super viewDidLoad];

UIBarButtonItem *actionButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showActionMenu:)];
actionButton.style = UIBarButtonItemStyleBordered;

UIBarButtonItem *searchButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(showSearchMenu:)];
searchButtonItem.style = UIBarButtonItemStyleBordered;

UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 103.0f, 44.01f)];
NSArray* buttons = [NSArray arrayWithObjects:actionButton, searchButtonItem, nil];
[toolbar setItems:buttons animated:NO];
self.navigationItem.title = @"Census Management";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolbar];


[[RKClient sharedClient] get:@"censusmanagement" delegate:self];
}

- (IBAction)showActionMenu:(id)sender
{
[self performSegueWithIdentifier: @"CMActionSegue" sender: self];
}

- (IBAction)showSearchMenu:(id)sender
{
ehrxCMSearchView *search = [[self storyboard] instantiateViewControllerWithIdentifier:@"cmSearch"];
search.selectedOptions = self.selectedOptions;

search.delegate = self;

[self.navigationController pushViewController:search animated:YES];
}

- (void)cancelSearch:(ehrxCMSearchView *)controller
{
[self dismissViewControllerAnimated:YES completion:nil];
}

最佳答案

您将使用类似于以下内容的方式关闭模态视图:

[self dismissModalViewControllerAnimated:YES];

这将关闭使用类似于以下内容加载的模态视图:
[self presentModalViewController:search animated:YES];

但是查看您的代码片段,似乎搜索 View Controller 正在使用以下行推送到导航堆栈:
[self.navigationController pushViewController:search animated:YES];

所以我可能需要从导航堆栈中弹出 View ,而不是试图将其作为模态视图关闭:
[self.navigationController popViewControllerAnimated:YES];

关于ios - 模态窗口没有被关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9811018/

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