gpt4 book ai didi

ios - UISearchbar searchBarTextDidEndEditing 未被调用

转载 作者:行者123 更新时间:2023-12-02 00:04:01 24 4
gpt4 key购买 nike

所以我有这个代码 -

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar{
NSLog(@"SEARCH BAR TEXT DID END EDITING");
[self handleSearchForSearchString:searchBar.text];
}

-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{
NSLog(@"SEARCH BAR BEGIN EDITING");
if(shouldBeginEditing) {
NSTimeInterval animationDuration = 0.3;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: animationDuration];
[UIView commitAnimations];
[self.searchDisplayController.searchBar setShowsCancelButton: YES animated:YES];
}
BOOL boolToReturn = shouldBeginEditing;
shouldBeginEditing = YES;
return boolToReturn;
}

searchBarShouldBeginEditing正在被调用,但是 searchBarTextDidEndEditing没有被调用。为什么会发生这种情况?

最佳答案

实现下面的方法

searchBarSearchButtonClicked

并确保您在上述方法中[UISearchchbar resignfirstresponder]。

关于ios - UISearchbar searchBarTextDidEndEditing 未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20797771/

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