关于 UISearchBar 的总结

iOS小技能: UISearchBar 搜索框使用教程(1、设置_UISearchBarSearchFieldBackgroundView 控件的圆角2、去掉UISearchBar搜索框的放大镜) + (UISearchBar*)homesearchBar { UISearchBar *searchBar = [[UISearchBar alloc]init]; [searchBar setImage:[UIImage imageNamed:@"search"] forSearchBarIcon:UISearchBarIconSearch state:UICont 阅读详情

最近用到搜索功能。于是,经过不断的研究,终于,有点懂了。

那就来总结一下吧,好记性不如烂笔头!


搜索,无疑可以使用UISearchBar控件!


那就先了解一下UISearchBar控件吧!



UISearchBar控件就是要为你完成搜索功能的一个专用控件。它集成了很多你意想不到的功能和特点!


首先,还是来普及一下UISearchBar控件API相关的属性和方法吧!


UISearchBar属性相关


_searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];// 初始化,不解释

    [self.searchBar setPlaceholder:@"Search"];// 搜索框的占位符

    [self.searchBar setPrompt:@"Prompt"];// 顶部提示文本,相当于控件的Title

    [self.searchBar setBarStyle:UIBarMetricsDefault];// 搜索框样式

    [self.searchBar setTintColor:[UIColor blackColor]];// 搜索框的颜色,当设置此属性时,barStyle将失效

    [self.searchBar setTranslucent:YES];// 设置是否透明

    [self.searchBar setBackgroundImage:[UIImageimageNamed:@"image0"]];// 设置背景图片

    [self.searchBar setSearchFieldBackgroundImage:[UIImageimageNamed:@"image3"] forState:UIControlStateNormal];// 设置搜索框中文本框的背景

    [self.searchBar setSearchFieldBackgroundImage:[UIImageimageNamed:@"image0"] forState:UIControlStateHighlighted];

    [self.searchBar setSearchFieldBackgroundPositionAdjustment:UIOffsetMake(30, 30)];// 设置搜索框中文本框的背景的偏移量

    

    [self.searchBar setSearchResultsButtonSelected:NO];// 设置搜索结果按钮是否选中

    [self.searchBar setShowsSearchResultsButton:YES];// 是否显示搜索结果按钮

    

    [self.searchBar setSearchTextPositionAdjustment:UIOffsetMake(30,0)];// 设置搜索框中文本框的文本偏移量

    

    

    

    [self.searchBar setInputAccessoryView:_btnHide];// 提供一个遮盖视图

    [self.searchBar setKeyboardType:UIKeyboardTypeEmailAddress];// 设置键盘样式

    

    // 设置搜索框下边的分栏条

    [self.searchBar setShowsScopeBar:YES];// 是否显示分栏条

    [self.searchBar setScopeButtonTitles:[NSArrayarrayWithObjects:@"Singer",@"Song",@"Album", nil]];// 分栏条,栏目

    [self.searchBar setScopeBarBackgroundImage:[UIImageimageNamed:@"image3"]];// 分栏条的背景颜色

    [self.searchBar setSelectedScopeButtonIndex:1];// 分栏条默认选中的按钮的下标

    

    

    [self.searchBar setShowsBookmarkButton:YES];// 是否显示右侧的“书图标”

    

    [self.searchBar setShowsCancelButton:YES];// 是否显示取消按钮

    [self.searchBar setShowsCancelButton:YES animated:YES];

    

    // 是否提供自动修正功能(这个方法一般都不用的)

    [self.searchBar setSpellCheckingType:UITextSpellCheckingTypeYes];// 设置自动检查的类型

    [self.searchBar setAutocorrectionType:UITextAutocorrectionTypeDefault];// 是否提供自动修正功能,一般设置为UITextAutocorrectionTypeDefault

    

    self.searchBar.delegate = self;// 设置代理

    [self.searchBar sizeToFit];

    myTableView.contentInset =UIEdgeInsetsMake(CGRectGetHeight(self.searchBar.bounds), 0, 0, 0);


    

    [self.view addSubview:myTableView];

    

    [myTableView addSubview:self.searchBar];



这么多属性,其实看起来多,你实际去操作事件一下,就发现很简单的!

绝大多部分都是定义一些外观的东西!了解了各个属性,一定能满足你设计出你想要的外观效果!!


然后,解释一下,我个人觉的比较有趣和重要的属性!


1.@property (nonatomic, readwrite, retain) UIView *inputAccessoryView;属性


例如:


[self.searchBar setInputAccessoryView:your_View];// 提供一个遮盖视图


当处于UISearchBar焦点状态下(输入框正要输入内容时),会有一个遮盖视图。


你翻看一下,iPhone手机上的电话本搜索功能。那个遮盖视图就是一个半透明的黑色View。




查看了一下API,是iOS 6.0 以及以后,新加入的!

那么就意味这 iOS 6.0 之前的系统是不兼容的。那么怎么才能达到这个类似的效果呢?

变通一下,其实,很简单:仍然设置一个按钮,初始状态下,该UIButton控件透明度设置为0;并且在控件取得焦点时,设置透明度为1。

小技巧:如果要设置这个属性,那么,就最好定义一个UIButton控件,这样,当点击该遮盖层的话,可以利用按钮事件,

设置:[self.searchBar resignFirstResponder];让搜索框放弃第一焦点。(iPhone电话薄也是这么做的,感觉很人性化)。


迷惑:还有一个小的问题:当我让UISearchBar显示取消按钮时,当我让UISearchBar失去焦点时,我的取消按钮也不能点击了。衰啊。

看了一下iPhone电话薄的UISearchBar,竟然可以也,找了很久,都不知道是怎么回事,大概苹果又开始玩私有API了吧。

解决方法:很暴力,但是很好用!在UISearchBar上原来取消按钮的位置上覆盖一个UIButton,设置成一样的。呵呵。可以了。


类似如下:


// 遮盖层

_btnAccessoryView=[[UIButton alloc] initWithFrame:CGRectMake(0, 44,BOUNDS_WIDTH, BOUNDS_HEIGHT)];

[_btnAccessoryView setBackgroundColor:[UIColor blackColor]];

[_btnAccessoryView setAlpha:0.0f];

[_btnAccessoryView addTarget:selfaction:@selector(ClickControlAction:)forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:_btnAccessoryView];



// 遮罩层(按钮)-点击处理事件

- (void) ClickControlAction:(id)sender{

    NSLog(@"handleTaps");

    

    [self controlAccessoryView:0];


}



// 控制遮罩层的透明度

- (void)controlAccessoryView:(float)alphaValue{

    

    [UIView animateWithDuration:0.2 animations:^{

        //动画代码

        [self.btnAccessoryView setAlpha:alphaValue];

    }completion:^(BOOL finished){

        if (alphaValue<=0) {

            [self.searchBar resignFirstResponder];

            [self.searchBar setShowsCancelButton:NO animated:YES];

            [self.navigationController setNavigationBarHidden:NOanimated:YES];


        }

        

    }];

}


2.@property(nonatomic,assign) id<</b>UISearchBarDelegate> delegate;属性


例如:


self.searchBar.delegate = self;


说到这个属性,就是设置委托了。


UISearchBarDelegate委托定义了很多关于,搜索框的一些操作数据的协议方法!


先来个,特写,把x协议的家庭成员列出来:


@protocol UISearchBarDelegate


@optional


- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar;

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar;

- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar;

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar;

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText;

- (BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text; 

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar;

- (void)searchBarBookmarkButtonClicked:(UISearchBar *)searchBar;

- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar;

- (void)searchBarResultsListButtonClicked:(UISearchBar *)searchBar;


- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope;


@end


这不需要解释吧,看方法名称就能了解!


我们来看一看,常用的委托方法吧。


#pragma mark - UISearchBarDelegate 协议


// UISearchBar得到焦点并开始编辑时,执行该方法

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{

    [self.searchBar setShowsCancelButton:YES animated:YES];

    [self.navigationController setNavigationBarHidden:YESanimated:YES];

    [self controlAccessoryView:0.9];// 显示遮盖层。

    return YES;


}


// 取消按钮被按下时,执行的方法

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar{

    [self.searchBar resignFirstResponder];

    [self.searchBar setShowsCancelButton:NO animated:YES];

    [liveViewAreaTable searchDataBySearchString:nil];// 搜索tableView数据

    [self.navigationController setNavigationBarHidden:NOanimated:YES];

    [self controlAccessoryView:0];// 隐藏遮盖层。

    

}


// 键盘中,搜索按钮被按下,执行的方法

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{

    NSLog(@"---%@",searchBar.text);

    [self.searchBar resignFirstResponder];// 放弃第一响应者

    [liveViewAreaTable searchDataBySearchString:searchBar.text];

    [self.navigationController setNavigationBarHidden:NOanimated:YES];

    [self controlAccessoryView:0];// 隐藏遮盖层。


}


// 当搜索内容变化时,执行该方法。很有用,可以实现时实搜索

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString*)searchText;{

    NSLog(@"textDidChange---%@",searchBar.text);

    [liveViewAreaTable searchDataBySearchString:searchBar.text];// 搜索tableView数据

    [self controlAccessoryView:0];// 隐藏遮盖层。


}


3.遍历UISearchBar控件的子控件,这样可以针对不同的子视图来设置外观了。


for(id subView in [self.searchBar subviews]){

        if([subView isKindOfClass:[UIButton class]]){

            UIButton *btn = (UIButton *)subView;

            [btn setTitle:@"取消"  forState:UIControlStateNormal];

        }  

    }



当然,不是很全。也是入门的级别,见效了!



希望对你有所帮助! 
手把手教你学Simulink——基础储能管理场景实例:基于Simulink的压缩空气储能(CAES)系统简化模型仿真 本文介绍了基于Simulink的压缩空气储能(CAES)系统简化模型仿真方法。CAES作为大规模长时储能方案,相比锂电池具有成本低、寿命长等优势。文章详细讲解了AA-CAES系统组成、热力学建模理论,以及Simulink实现流程,包括储气室、压缩机、膨胀机等核心模块的建模方法。通过8小时充电(50MW)和6小时放电(40MW)的仿真,验证了系统可实现60%往返效率。该模型为理解CAES系统运行机制提供了实用工具,并指出热管理、储气室特性等工程实践要点,为新型电力系统储能规划提供了仿真基础。 阅读详情

相关推荐

Zemax物理光学实战:3分钟搞定高斯光束传播模拟(附菲涅尔局部分析技巧)

本文详细介绍了在Zemax中进行高斯光束传播模拟与菲涅尔局部分析的实战技巧。通过3分钟快速设置指南和参数解析,帮助光学工程师准确模拟激光光束特性,避免常见误区。特别分享了菲涅尔局部分析的关键技巧和传播参数优化策略,提升光学系统设计的精度与效率。

lambda的博客 804

UISearchBar控件 使用(转载)

最近用到搜索功能。于是,经过不断的研究,终于,有点懂了。 那就来总结一下吧,好记性不如烂笔头! 搜索,无疑可以使用UISearchBar控件! 那就先了解一下UISearchBar控件吧! UISearchBar控件就是要为你完成搜索功能的一个专用控件。它集成了很多你意想不到的功能和特点! 首先,还是来普及一下UISearchB

snsogblgbl的专栏 760

比亚迪璇玑架构:10ms级响应引领智能驾驶革命

比亚迪璇玑架构通过三大创新,实现10ms级控制响应时延,使AEB刹车距离比竞品缩短20米。

百态·数智思维 | 聚焦大数据、量化与未来AI 1255

亲测UISearchBar Delegate的11个方法和UISearchDisplay Delegate的12个方法的调用顺序

UISearchBar所在的viewController(以下简称mainVC)的- (void)viewDidLoad方法中的代码如下: [super viewDidLoad];     //searchBar     self.searchBar = [[UISearchBar alloc] init];     self.searchBar.frame = CGRectMa

swj6125的专栏 2万+

“华为”云桌面系统声音比较小,如何调大?

调整操作系统声音 开启云桌面,登录账户之后,进入操作系统,鼠标左键点击右下角的声音图标,把声音调到最大(如下图); 可以考虑使用浏览器在线听音乐,确定声音的音量! 如果只是耳麦声音小,可以鼠标右键点击声音图标,选择录音设备(R),如下图: 点击“录音设备(R)”后进入,鼠标右键点击“麦克风”选择属性,将侦听级别调至最大,确定! 调整华为云终端声音(软设置) 将鼠标移至桌面的顶端中间位置,打开如下图的样式图标,鼠标左键点击“主页”; 点击“主页”之后,将回到云桌面的终端操作界面,

shunchang的专栏 2336

【Bug已解决】Codex capacity errors 自动重试与意图保留 解决方案

原始报错:Codex Desktop: capacity errors should preserve intent and auto-retry instead of handing model routing back to the user场景:向模型服务发请求时遇到容量错误(服务端繁忙 / 限流 / 容量不足),客户端不做任何重试,直接把"请求失败,请选择另一个模型或重试"的锅甩给用户,让用户手动去点。用户本来只是想完成一次任务,却被中途打断去当"调度员"。

博客 278

iOS自定义UISearchBar,简单、方便、好用

可恶的UI非要搞一个和系统的UISearchBar的不一样的效果,但是系统自带的用实现不了效果,就自能自定义了。把一个UISearchBar放到UINavigationBar上。并且还要有搜索的结果在整个页面上。。。先看看效果图 HZSearchBar自定义searcher,完全模仿系统样式选择遵循协议 CustomsearchResultsUpdater 及时筛选代理同系统的searchResu...

whuizhou的专栏 4274

C# 上位机之海康工业相机开发(SDK)实战教程

海康工业相机的C#开发核心是基于MVS SDK的“初始化→枚举→连接→采集→释放”流程,其中图像回调处理和格式转换是关键。严格按照SDK文档处理设备类型(网口/USB)和像素格式;及时释放图像资源,避免内存泄漏;错误码是排查问题的重要依据(可参考SDK中的“错误码说明”文档)。掌握这些基础后,可结合机器视觉算法(如OpenCV)实现缺陷检测、尺寸测量等高级功能,构建完整的工业视觉系统。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 3829

[iOS]关于UISearchBar, 看这个就够了

UISearchBar一般我们不单独使用他, 在iOS 8之后, 我们更多地是和UISearchController一起使用, 关于UISearchController的一些使用可参考[iOS]系统UISearchController详解, 这里主要是关于UISearchBar的一些设置, 可以单独使用, 也可以对UISearchController中的searchBar 进行设置. 下面这个就是

流火緋瞳的博客 1万+

LVGL hal disp(porting display)

LVGL本身是没有对接最终的显示框架的,所以到具体的某个平台上,需要自行porting。

Bigan(安)的博客 2097

OpenClaw进阶实战(二十三):微信公众号接入——被动回复、客服消息、素材管理

本文介绍了将OpenClaw接入微信公众号的完整方案,重点包含以下内容: 接入方案选型:对比官方插件、三方服务和自建中转三种方式,选择自建Node.js中转服务实现灵活控制 核心原理:通过中转服务器完成微信消息协议转换,处理5秒超时限制和异步回复机制 实战开发: 搭建Express中转服务 实现Token管理和消息处理 采用内存缓存对话历史 通过客服接口异步回复 官方插件方案:介绍2026年发布的ClawBot插件,支持文本/图片/文件收发 进阶功能:包括素材管理接口调用示例 该方案适用于需要深度定制公众号

PeterPan的博客 142

UiSearchBar圆角设置

有时我们可能会遇到这样的需求:如图搜索框两边是圆形的,当然这样的效果有很多方法来实现,但是个人感觉有点麻烦,今天我们用UISearchBar来实现上面的效果;具体实现思路是我们得到UISearchBar的子视图UITextField来设置其圆角,在系统的UISearchBar中UITextfield是这样的命名的searchField所以我们只要利用KVC得到就可以,具体实现代码如下: UITe

半桶水技术的博客 7517

PX4从放弃到精通(十一):混控及PWM输出

文章目录前言一、混控脚本二、使用步骤1.引入库2.读入数据总结 前言 一个人可以走的更快,一群人才能走的更远,交流学习加qq:2096723956 更多保姆级PX4+ROS学习视频:https://b23.tv/ZeUDKqy 分享知识,传递正能量,如有疏漏或不当之处,恳请指出. 一、混控脚本 混控脚本定义了不同 示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。 二、使用步骤 1.引入库 代码如下(示例): import numpy as np import pand

超维空间科技的博客 1万+

swift中UISearchBar的使用

// 实例化 let searchbar = UISearchBar(frame: CGRectMake(10.0, 10.0, (CGRectGetWidth(self.view.frame) - 10.0 * 2), 40.0)) self.view.addSubview(searchbar) searchbar.backgroundColor = UIColor.yello

番薯大佬的专栏 2848

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

UISearchBar

UISearchBar是系统自带的搜索控件 继承于UIView 一.相关属性 seacbar.prompt = @"顶部提示信息"; seacbar.placeholder = @"我是占位文字"; seacbar.text = @"我是搜索的文字"; //右侧按钮相关 四个按钮默认NO //...

江苏小白龙 1212

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

uisearchbar_如何在uisearchbar中添加活动加载器

uisearchbar 访问UISearchBar的UITextField (Accessing the UITextField of UISearchBar) We know that Apple has not made it easy for us to access the UITextField reference on different OS. So here is the code...

weixin_26735419的博客 116

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

UISearchBar的使用

UISearchBar功能与UITextField类似,也是单行字符输入框 常用用途:用于搜索功能的实现 使用注意事项: 1、书签按钮属性与搜索回车按钮属性不能同时进行设置,只能二选一,否则会出现冲突 2、键盘中的回车按钮,默认是有输入的条件下才能进行点击响应 3、不能修改其输入源视图,默认是键盘 4、注意键盘的显示和隐藏,以及对输入控件的遮挡处理 5、通

番薯大佬的专栏 2317

uisearchbar_如何在uisearchbar中更改搜索图标

uisearchbar 让我们从UITextField开始 (Let’s start with UITextField) As you probably know, Apple has made not easy for us to access the UITextField reference on other OS versions. So here’s the code to help y...

weixin_26735419的博客 1004

UISearchBar用法

UISearchBar基本用法

浮生若梦 为欢几何 3556

UISearchBar和UISearchDisplayController

原文 http://hi.baidu.com/happywilma0118/item/e6d5730a499bba1b3a53eef8  UISearchBar继承自UIView、UIResponder、NSObject   属性: autocapitalizationType————自动对输入文本对象进行大小写设置(包含4种类型,但是有时候键盘会屏蔽此属性)  autocorrection

Flying_in_the_world的专栏 427

iOS UISearchBar使用 —— HERO博客

iOS UISearchBar使用,搜索模型数组。

hero_wqb的博客 794

UISearchBar背景色及边框修改

UISearchBar背景色修改以及边框黑线去除

Paddy的个人博客 3814

UISearchBar使用记录

UISearchBar *_listSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, [Globle shareInstance].globleWidth, 44.0)]; me.backgroundColor = RGB(0xf6, 0xf6, 0xf6); ((UISearchBar *)me).ti

Inkywang的专栏 4439

UISearchbar 及修改其背景图片

UISearchBar  searchbar =[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];         searchbar.showsCancelButton=NO;         searchbar.barStyle=UIBarStyleDefault;       //searchbar按键类型,此处默认

井中月 2254

如何自定义UISearchBar

众所周知,iOS提供了非常方便的UISearchBar控件,用来开发页面上的搜索功能。但是有时候我们想要自定义,比如加个背景色,比如更改字体,比如修改样式,加个下拉菜单,并不是那么容易的,因为iOS没有提供更具体的这类的接口给开发者,那么怎么办呢,其实也是有办法的。UISearchBar本质上也是由很多我们已知的控件所构成的,比如UITextField,UIButton等,我们只要取到这些控件,就

宿命 宽恕 轮回 4971
上一篇: CocoaPods降低版本及卸载
下一篇: 关于 UIButton 的总结
style_施
博客等级 码龄11年 11粉丝 42原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值