Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望能够获取用户在搜索栏中输入的文本,并比较数组中的单词。但我不确定如何从搜索栏中获取文本,我知道在 java 中它只是 getText。
假设您命名为UISearchBarjust searchBar,您可以使用检索文本
UISearchBar
searchBar
searchBar.text
在 SearchBar Delegate 方法中,您可以获得搜索栏文本
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { NSString *str = searchBar.text; NSLog(@"%@",str); }