iphone:Search-bars
出自UXGuide.net
请帮助我们修订和更新本文的译文部分
本文的译文部分可能是由多个贡献者提供或从不同的渠道收集,未经过最终审阅和整理,请您帮助我们一起修订和更新本文的译文部分。
搜索栏
Search Bars
A search bar is a field that accepts text from users, which your application can use as input for a search. When the user taps a search bar, a keyboard appears; when the user is finished typing search terms, the input is handled in an application-specific way. (For guidelines on handling search in your application, see “Providing Search and Displaying Search Results.”)
搜索栏是一个接受用户输入文本的域,你的应用程序可以使用这些文本来搜索。当用户点击一个搜索栏,键盘显示,当用户完成搜索条件的输入,输入以特定应用程序的方式处理。(关于在你的程序中应用搜索的指南,请参阅“提供搜索和显示搜索结果“)。
By default, a search bar displays the search icon on the left side. In addition, a search bar can display a few optional elements:
默认情况下,搜索图标显示在搜索栏的左侧。此外,搜索栏可以显示一些可选的元素:
- Placeholder text. This text might state the function of the control (for example, “Search”) or remind users in what context they are searching (for example, “YouTube” or “Google”).
- 占位符文本。这些文字可能是强调控件的功能(例如,“搜索”),或提醒他们是在什么引擎中搜索(例如,“YouTube”或“Google”)。
- The Bookmarks button. This button can provide a shortcut to information users want to easily find again. For example, the Bookmarks button in the Maps search mode gives access to bookmarked locations, recent searches, and contacts.
- 书签按钮。这个按钮可以提供一个快捷的信息便于用户再次找到它。例如,在地图搜索模式书签按钮提供了进入书签所定位的位置的入口,最近的搜索和联系人信息。
- The Clear button. Most search bars include a Clear button that allows users to erase the contents of the search bar with one tap.
- 清除按钮。大多数搜索栏都包括一个清除按钮,允许用户通过点击清除按钮删除搜索栏里的内容。
- A descriptive title, called a prompt, that appears above the search bar. For example, a prompt can be a short phrase that provides introductory or application-specific context for the search bar.
- 描述性标题,或称为提示,出现在搜索栏的上方。例如,提示可以是一个短语,为搜索栏提供前言的或者应用程序具体的介绍。
Figure 9-10 shows a search bar that includes customized placeholder text, a Bookmarks button, and the default search icon.
图9-10显示了一个搜索栏,其中包括自定义的占位符文本,书签按钮,默认搜索图标。
Figure 9-10 A search bar with optional placeholder text and a Bookmarks button
图9-10 带有可选的占位符文本和书签按钮的搜索栏
By default, the Bookmarks and Clear buttons interact in the following ways:
默认情况下,书签和清除按钮通过以下方式交互:
- When the search bar contains any non-placeholder text, the Clear button is visible so users can erase the text. If there is no user-supplied or non-placeholder text in the search bar, the Clear button is hidden because there is no need to erase the contents of the search bar.
- 当搜索栏包含任何非占位符文本时,清除按钮就会显示,用户可以删除文本。如果搜索栏里没有用户提供的文本或非占位符文本,清除按钮会被隐藏,因为没有必要抹去搜索栏的内容。
- The Bookmarks button is visible only when there is no user-supplied or non-placeholder text in the search bar. This is because the Clear button is visible when there is text in the search bar that users might want to erase.
- 当搜索栏里没有用户提供的文本或没有非占位在文本时,书签按钮显示。这是因为在用户可能需要清除搜索栏里的文本时,清除按钮才显示。
You can customize a search bar by specifying one of the standard-color background styles, such as:
你可以通过指定一个标准色背景样式来自定义搜索栏,比如:
- Blue (the default gradient that coordinates with the default appearance of toolbars and navigation bars). The default background style is shown in Figure 9-10.
- 蓝色(默认的渐变色,与工具栏和导航栏的外观相协调)。默认背景样式如图9-10。
- Black
- 黑色
In addition, you can display a scope bar below the search bar, which contains buttons that users tap to select a scope for the search. The scope bar adopts the same appearance you specify for the search bar, and you supply custom titles for the scope buttons.
此外,你可以在搜索栏下面显示范围栏,其中包含那些用户点击之后可以选择一个搜索范围的按钮。范围栏采用了和你指定的搜索栏相同的外观,并为你可以提供自定义的范围按钮标题。
The scope bar displays below the search bar, regardless of orientation, unless you use a search display controller in your code (see UISearchDisplayController Class Reference for more information). When you use a search display controller, the scope bar is displayed within the search bar to the right of the search field when the device is in landscape orientation (in portrait orientation, it’s below the search bar).
范围栏显示在搜索栏的下方,不分方向,除非你在代码中使用搜索显示控制器(更多信息,见 UISearchDisplayController 类型参考)。当你使用搜索显示控制器时,如果设备是横向显示的,范围栏处于搜索栏中,且在搜索输入区域的右边。
To learn more about using a search bar and scope bar in your code, see UISearchBar Class Reference.
要了解更多有关在代码中使用搜索栏和范围栏的信息,请参阅 UISearchBar 类型参考。