Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 通过点击键盘上的搜索触发序列_Ios_Keyboard_Uistoryboard_Segue - Fatal编程技术网

Ios 通过点击键盘上的搜索触发序列

Ios 通过点击键盘上的搜索触发序列,ios,keyboard,uistoryboard,segue,Ios,Keyboard,Uistoryboard,Segue,我有一个应用程序,我希望用户点击一个文本字段,输入他们的搜索查询,然后点击键盘上的返回(或这里的搜索)按钮。这样做会触发一个segue,并将prepareforsgue方法中的一些数据发送给下一个控制器 这个方法目前是由UIButton触发的,它工作正常,但我希望在键盘上点击Search时发生完全相同的事情,这样我就可以删除按钮并简化过程 我已尝试在文本字段中调用[self prepareforsgue](代理的)shouldReturn方法,但没有成功 - (void)prepareForSe

我有一个应用程序,我希望用户点击一个文本字段,输入他们的搜索查询,然后点击键盘上的返回(或这里的搜索)按钮。这样做会触发一个segue,并将
prepareforsgue
方法中的一些数据发送给下一个控制器

这个方法目前是由UIButton触发的,它工作正常,但我希望在键盘上点击Search时发生完全相同的事情,这样我就可以删除按钮并简化过程

我已尝试在
文本字段中调用
[self prepareforsgue]
(代理的)shouldReturn
方法,但没有成功

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString: @"DisplaySearchResults"]) {
        SearchResultsViewController *searchResultsViewController = [segue destinationViewController];
        searchResultsViewController.searchQuery = _searchQuery;
    }
}
你应该打电话

[self performSegueWithIdentifier:@"DisplaySearchResults" sender:self];
在textfield中应该返回

prepareForSegue将在PerformsgueWithIdentifier之后自动调用。

您应该调用

[self performSegueWithIdentifier:@"DisplaySearchResults" sender:self];
在textfield中应该返回


prepareForSegue将在PerformsgueWithIdentifier后自动调用。

这将起作用,只需确保父类是该UITextField的委托。只需隐藏键盘,即可在文本字段上启动推送序列设置。请看这是否可行,只需确保父类是该UITextField的委托。只需隐藏键盘,即可在文本字段上启动推送序列设置。看见