ios中,在SearchBar里面搜索内容,可根据内容来查找所需的信息资源,可获得SearchBar中的内容
贴一段我很久以前写的小demo,你们就明白了,是把textField套在alertView里的
@interface ViewController : UIViewController <UIAlertViewDelegate, UITextFieldDelegate>{
UILabel *la;
UITextField *myTextField;
} @implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad]; la = [[UILabel alloc] init];
la.Frame = CGRectMake(10, 150,300,30);
la.backgroundColor = [UIColor clearColor];
la.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
la.text = @"initLabel";
la.textAlignment = UITextAlignmentCenter;
la.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.75f];
la.shadowOffset = CGSizeMake(0.0f, 5.0f); la.textColor = [UIColor greenColor]; [self.view addSubview:la]; UIButton *alartBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
alartBtn.frame = CGRectMake(110, 50, 50, 50);
alartBtn.backgroundColor = [UIColor clearColor];
[alartBtn setTitle:@"alart" forState:UIControlStateNormal];
[alartBtn addTarget:self action:@selector(alartShow:) forControlEvents:UIControlEventTouchUpInside];
[alartBtn setAlpha:1.0];
[self.view addSubview:alartBtn]; }
-(void)alartShow:(id)sender{ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Title" message:@" " delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"OK", nil];
[alert show];
[alert release]; myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)]; [myTextField setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:myTextField];
[myTextField setDelegate:self]; [myTextField addTarget:self action:@selector(onTextFieldChanged:forEvent:) forControlEvents:UIControlEventEditingChanged]; NSLog(@"myTextField.text:%@", myTextField.text); } - (void)alertView: (UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
{ NSLog(@"%@", myTextField.text);
la.text = myTextField.text; }
} - (void)alertView:(UIAlertView *)alert didDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex == [alert cancelButtonIndex]) {
close(0);
} } - (void) onTextFieldChanged:(id)sender forEvent:(UIEvent *)event{ NSLog(@"%@", myTextField.text);
}
摘出来的,大概意思应该已经有了,有用的自己在看下。。。欢迎技术交流,彼此进步。。谢谢。。
ios中,在SearchBar里面搜索内容,可根据内容来查找所需的信息资源,可获得SearchBar中的内容的更多相关文章
- iOS中的两种搜索方式UISearchDisplayController和UISearchController
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 以前iOS的搜索一般都使用UISearchDisplayCon ...
- iOS中利用UISearchBar实现搜索
先把源码贴出来 https://github.com/losedMemory/ZSSearchBar 这是我在github上写的一个Demo,大家可以看看 在大多数app中都会用到搜索功能,那么搜 ...
- iOS学习之NSPredictae及搜索框的实现
NSPredicate Predicate 即谓词逻辑, Cocoa框架中的NSPredicate用于查询,作用是从数据堆中根据条件进行筛选.计算谓词之后返回的结果永远为BOOL类型的值,当程序使用谓 ...
- iOS 9之应用内搜索(CoreSpotlight)API
金田(github 示例源码) 前言 在iOS9之前我们只能使用Spotlight来搜索应用名称来打开指定App,而其他的内容都是提供给系统使用(信息,联系人,邮件等).在iOS9以后Apple允许开 ...
- ios下虚拟键盘出现"搜索"字样
最近在开发过程中,发现用户输入想要检索的内容,弹出虚拟键盘,在安卓机上虚拟键盘最右下角会有‘搜索’字样,而ios上虚拟键盘最右下角只有‘换行’字样, 这样用户体验就会大打折扣. 安卓机上虚拟键盘 io ...
- 对图片进行索引,存入数据库sqlite3中,实现快速搜索打开
对图片进行索引,存入数据库中,实现快速搜索打开 这个任务分为两步: 第一步:建立索引 import os import shutil import sqlite3 # 扫描函数,需扫描路径目录处 ...
- WCF 在VS中,添加服务引用,地址输入http://ip/Service.svc,点击前往,提示错误,内容如下:
WCF的service端的webconfig如下: <?xml version="1.0"?> <configuration> <system.ser ...
- LoadRunner如何获得参数化中每个关键字的搜索响应时间
LoadRunner如何获得参数化中每个关键字的搜索响应时间 在测试搜索引擎时我们一般采用大量的搜索关键字,有时有必要了解在并发访问的情况下每个关键字的响应时间,一般如果不对脚本进行处理的话你可以获得 ...
- 如何从统计中批量获取BD搜索关键词及对应的入口页面?
前面我们介绍了通过cnzz的访问明细获取到搜索关键词及对应的入口页面,但是从BD搜索进来的关键词无法完整显示,只能呈现一些bd图片搜索的关键词,这是因为百度宣布从去年5月开始逐渐取消了referer关 ...
随机推荐
- LeetCode() Basic Calculator 不知道哪里错了
class Solution {public: int calculate(string s) { stack<int> num; stack<ch ...
- C/C++中const的用法 分类: C/C++ 2015-07-05 00:43 85人阅读 评论(0) 收藏
const是C语言的关键字,经C++进行扩充,变得功能强大,用法复杂.const用于定义一个常变量(只读变量),当const与指针,引用,函数等结合起来使用时,情况会变得复杂的多.下面将从五个方面总结 ...
- LEETCODE —— Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...
- (转)A Survival Guide to a PhD
Andrej Karpathy blog About Hacker's guide to Neural Networks A Survival Guide to a PhD Sep 7, 2016 T ...
- 数据库中Schema和Database有什么区别
在MySQL中创建一个Schema好像就跟创建一个Database是一样的效果,在SQL Server和Orcal数据库中好像又不一样. 目前我只能理解,在mysql中 schema<==> ...
- 【转】windows server 2012清除并重建SID
windows server 2012清除并重建SID 2012-09-17 17:51:51 标签:SID windows server 2012 原创作品,允许转载,转载时请务必以超链接形式标明文 ...
- 入侵本地Mac OS X的详细过程 转自https://yq.aliyun.com/articles/22459?spm=5176.100239.blogcont24250.10.CfBYE9
摘要: 本文从提升权限漏洞的一系列巧妙的方法来绕过受保护的Mac OS X.有些已经被处于底层控制,但由于它们存在着更多的认证和修补程序,我们不妨让这些提供出来,以便需要的人学习它们.虽然我不只是要利 ...
- HttpClientUtil [使用apache httpclient模拟http请求]
基于httpclient-4.5.2 模拟http请求 以get/post方式发送json请求,并获取服务器返回的json -------------------------------------- ...
- HTML JavaScripts
JavaScript JavaScript是一门编程语言,浏览器内置了JavaScript语言的解释器,所以在浏览器上按照JavaScript语言的规则编写相应代码之,浏览器可以解释并做出相应的处理. ...
- 手机网页调试利器: Chrome
新开发的网页需要在手机或是模拟机上运行测试, 可以借助 Chrome提供的手机网页预览程序进行简单调试.查看 制作的网页是否能够适合各种手机型号使用. 下面所以下如何使用Chrome调试多类型手机网页 ...