button分次点击效果不同(点击button隐藏一个视图,再次点击该视图显示,如此循环)
2014-01-15 10:06
295 查看
//创建一个button,添加在控制器视图
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
addButton.backgroundColor = [UIColor clearColor];
addButton.frame = CGRectMake(0, 440, 40, 40);
[addButton addTarget:self action:@selector(add:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addButton];
//创建一个视图,视图上可以放置其他button,从而达到节省空间的效果.其中.aView为uiview类的属性.
self.aView = [[UIView alloc] initWithFrame:CGRectMake(40, 420, 320, 60)];
self.aView.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.aView];
self.aView.hidden = YES;
//触发的方法
实现机理为循环改变视图的隐藏性.
- (void)add:(UIButton *)button
{
if (self.aView.hidden == NO) {
self.aView.hidden = YES;
}else{
self.aView.hidden = NO;
}
}
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
addButton.backgroundColor = [UIColor clearColor];
addButton.frame = CGRectMake(0, 440, 40, 40);
[addButton addTarget:self action:@selector(add:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addButton];
//创建一个视图,视图上可以放置其他button,从而达到节省空间的效果.其中.aView为uiview类的属性.
self.aView = [[UIView alloc] initWithFrame:CGRectMake(40, 420, 320, 60)];
self.aView.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.aView];
self.aView.hidden = YES;
//触发的方法
实现机理为循环改变视图的隐藏性.
- (void)add:(UIButton *)button
{
if (self.aView.hidden == NO) {
self.aView.hidden = YES;
}else{
self.aView.hidden = NO;
}
}
相关文章推荐
- 一个程序在后台运行(即隐藏了窗体), 如果再次点击exe时则显示出已运行的程序窗体。
- 在页面中,我们经常看到,一个button按钮,如果属标点击,就会触发一个窗口的显示,如果二次点击并可以隐藏,那么如何通过JAVA配合html来实现这一功能呢?
- 一个窗口里包含一个iframe,点击iframe内的submit按钮,返回的视图总是显示在iframe中,我想要的效果是点击按钮后返回的视图是在浏览器窗口中...?asp.net mvc 的action中,不用js怎么实现??????????
- 当点击一个View时,显示下面隐藏的一个View(折叠的动画效果)
- Android问题集(二)——TextView在点击时显示不同颜色,Button点击效果
- 使用jquery点击一个实现button或连接,进行以下div显示,在点击隐藏
- jquery tree循环渲染数据,控制checkbox显示与隐藏,点击无效效果
- vueJS简单的点击显示与隐藏的效果【实现代码】
- JavaScript点击一个按钮隐藏和显示div
- 请问如何在Web页面中点击一个button之后,用jsp从数据库中读取数据显示到表格里
- 点击显示隐藏菜单,动画效果,半透明,支持所有浏览器
- jq效果 点击隐藏和显示(组织冒泡事件)
- 设置一个View,让其在按下和不按下显示不同的效果
- 如果写一个点击view带动画的下滑展开显示隐藏内容的控件
- js控制div样式显示与隐藏,JS通过点击超链接右边(指定位置)显示一个图标
- 点击显示隐藏菜单,动画效果,半透明,支持所有浏览器
- 原生JS实现隐藏显示图片 JS实现点击切换图片效果
- 网页中有两个table, 默认只显示第一个table,点击一个按钮后显示第二个table,第一个table隐藏
- Android中同一个button按钮每次点击响应不同的事件
- js菜单点击显示或隐藏效果的简单实例