与UITextField相比,使用UISearchBar有什么优势?

时间:2020-06-30 19:20:02

标签: swift search uikit uitextfield uisearchbar

我正在通过自定义样式的搜索栏将搜索功能实现为应用程序的一部分。据我所知,自定义内置的UISearchBar似乎有点麻烦。因此,我想知道是否有人可以指出使用UISearchBar而不是UIView中的UITextField的优点,而UIView中的UITextField可以轻松自定义以符合我的方式?我看不到为什么无法像UISearchBar一样过滤UITextField if(isset($_GET['delete_id'])){ echo 'Do you want to delete '.$_GET['delete_id']. '? <br>'; echo '<form method="get">'; echo '<input type="hidden" name="delete_id" value="'.$_GET['delete_id'].'" />'; echo '<input type="submit" name="delete_yes" value="Yes" style="margin: 10px; position: absolute; top: 60px; "></input>'; echo '<input type="submit" name="delete_no" value="No" style="margin: 10px; position: absolute; top: 60px; left: 55px; "></input>'; echo '</form>'; } if(isset($_GET['delete_yes'])){ echo 'deleted '.$_GET['delete_id']; } 事件上的数据。我感谢任何指点!

1 个答案:

答案 0 :(得分:0)

我个人不建议在searchController或searchBar上实现文本字段,因为最后一个为您提供了有用的工具,可简化在搜索中的事件处理,例如presentationContext和UISearchResultsUpdating。手动处理这些示波器很痛苦。我知道自定义选项对某些开发人员来说很麻烦,但并非不可能。另外:从长远来看,将很难维护。