apicloud UISearchBar 使用方法
app中经常会有搜索的页面。
大概逻辑是,一般来说首页有一个搜索的图,点击之后跳转到一个搜索的页面,在这个页面做搜索。
正常代码逻辑
<body>
<a class="button" tapmode="active" onclick="open_s()">打开搜索页面</a>
<a class="button" tapmode="active" onclick="close_s()">关闭搜索页面</a>
<a class="button" tapmode="active" onclick="setText_s()">设置搜索框的文字</a>
<a class="button" tapmode="active" onclick="clearHistory_s()">清空当前搜索历史记录</a>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
apiready = function() {
api.addEventListener({
name : 'shake'
}, function(ret, err) {
console.log();
close_s()
});
}; function open_s() {
var UISearchBar = api.require('UISearchBar');
UISearchBar.open({
placeholder: '请输入搜索关键字',
historyCount: ,
showRecordBtn: true,
texts: {
cancelText: '取消',
clearText: '清除搜索记录'
},
styles: {
navBar: {
bgColor: '#FFFFFF',
borderColor: '#ccc'
},
searchBox: {
bgImg: '',
color: '#000',
height:
},
cancel: {
bg: 'rgba(0,0,0,0)',
color: '#D2691E',
size:
},
list: {
color: '#696969',
bgColor: '#FFFFFF',
borderColor: '#eee',
size:
},
clear: {
color: '#000000',
borderColor: '#ccc',
size:
}
}
}, function(ret, err) {
if (ret) {
alert(JSON.stringify(ret));
} else {
alert(JSON.stringify(err));
}
});
} function close_s() {
var UISearchBar = api.require('UISearchBar');
UISearchBar.close();
} function setText_s() {
var UISearchBar = api.require('UISearchBar');
UISearchBar.setText({
text: '设置语音识别的文本'
});
} function clearHistory_s() {
var UISearchBar = api.require('UISearchBar');
UISearchBar.clearHistory();
}
</script>
apicloud UISearchBar 使用方法的更多相关文章
- apicloud常用分享方法
app中经常会有分享的功能,不管是分享商品还是文字还是图片或者是发送给微信好友扣扣好友,一下做一总结. 分享的样式(分享所有的样式模块):MNActionButton. 在apicloud 中添加这个 ...
- iOS开发UI篇 -- UISearchBar 属性、方法详解及应用(自定义搜索框样式)
很多APP都会涉及到搜索框,苹果也为我们提供了默认的搜索框UISearchBar.但实际项目中我们通常需要更改系统默认搜索框的样式.为了实现这一目标,我们需要先搞懂 UISearchBar 的属性及方 ...
- 快捷搜索框(UISearchBar)简单实现 swift
1.在故事板里面拖入一个搜索栏和一个的tableView.2.创建的ViewController,实现代理:UISearchBarDelegate,UITableViewDataSource,的UIT ...
- 美团HD(5)-选择城市
DJSelectCityViewController.m #import "DJSelectCityViewController.h" #import "DJConsta ...
- 在navigationItem中添加搜索栏
给navigationItem中添加个搜索栏,效果和大部分程序一样.代码如下: UISearchBar *searchBar = [[UISearchBaralloc] initWithFrame:C ...
- 美团HD(7)-添加取消搜索按钮
DJSelectCityViewController.m #pragma mark - UISearchBar 代理方法 /** SearchBar开始编辑 */ - (void)searchBarT ...
- img标签过滤加fs模块实现图片文件缓存
方法一:function iCache(selector) { selector.each(function(data) { //msg(data); ! function(data) { var u ...
- javaSE27天复习总结
JAVA学习总结 2 第一天 2 1:计算机概述(了解) 2 (1)计算机 2 (2)计算机硬件 2 (3)计算机软件 2 (4)软件开发(理解) 2 (5) ...
- Apicloud学习第三天——获取云数据库的数据方法
apicloud学习30天中的对用进行注册和登录以及数据的获取的代码,在apicloud中有单独的api对用户的增删查改进行操作,这里写下增加和查询. 增加用户数据 var model=api.req ...
随机推荐
- ZooKeeper可以用来做什么(转)
在ZooKeeper的官网上有这么一句话:ZooKeeper is a centralized service for maintaining configuration information, n ...
- Source Insight 与 Source Navigator ,Understand ,Crystal FLOW 源代码阅读工具
http://www.sourceinsight.com/update.html http://www.oschina.net/p/sourcenavigator/ http://www.cnblog ...
- .NET Web API - 去掉讨厌的$id并且强制返回json格式
// 只返回json字符串,屏蔽自动选择xml格式的可能性,同时去掉讨厌的$id var json = config.Formatters.JsonFormatter; json.Serializer ...
- Codeforces Round #306 (Div. 2) D
D. Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Oracle数据库导出导入
需求为将数据库A中的数据导出为*.dmp文件.然后将*.dmp文件导入到数据库B. 1.导出数据库A 在cmd窗体输入下面命令: 导出所有数据库 exp username/password@数 ...
- AppFuse 3常见问题与解决方法
非常长一段时间没做SSH项目了.近期抽出时间看了一下升级到3.x的appfuse,对新版本号使用过程中出现的一些问题进行了排查.汇总例如以下.以备后用.本文原文出处: http://blog.csdn ...
- 苹果的编程语言--Swift
今天(2014-6-3)凌晨WWDC2014揭幕了,带来了新语言Swift,据说非常牛逼...所以就找了几个不错的link跟大家分享. 1.Swift的简单介绍,主要介绍了Swift的简单而经常使用的 ...
- oc48--多个对象内存管理练习
// // main.m // 多个对象内存管理练习 // // ARC是Xcode帮我们生成内存释放的代码,MRC是需要我买自己写retain和release.想研究内存管理只能在MRC,管理对象就 ...
- POJ 3264 Balanced Lineup (线段树)
Balanced Lineup For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the s ...
- 洛谷 P1032 [ NOIP 2002 ] 字串变换 —— 字符串+bfs
题目:https://www.luogu.org/problemnew/show/P1032 字符串好复杂...先写了个 dfs ,RE一个点TLE一个点,不知该怎么改了... #include< ...