iOS UITableView的Section Footer加入button
郝萌主倾心贡献,尊重作者的劳动成果。请勿转载。
假设文章对您有所帮助,欢迎给作者捐赠。支持郝萌主,捐赠数额任意。重在心意^_^
我要捐赠: 点击捐赠
Cocos2d-X源代码下载:点我传送
在处理UITableView表格时,我们希望在View底部加入button。
用户拖动UITableView时button能尾随移动。
如题。实现例如以下界面:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section >= kSetSetting) {
return 80;
}
else{
return 2;
}
} - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if (section >= kSetSetting)
{
UIView *footerView = [[UIView alloc] init];
footerView.userInteractionEnabled = YES;
footerView.backgroundColor = [UIColor clearColor]; UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
[loginButton.layer setMasksToBounds:YES];
[loginButton.layer setCornerRadius:5.0];
[loginButton setBackgroundColor:[UIColor brownColor]];
[loginButton setTitle:@"登陆" forState:UIControlStateNormal];
[loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[loginButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
[loginButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[loginButton addTarget:self action:@selector(loginBtnClick:) forControlEvents:UIControlEventTouchUpInside];
//[footerView addSubview:btnExit]; [footerView addSubview:loginButton]; UIButton *registerButton = [UIButton buttonWithType:UIButtonTypeSystem];
[registerButton.layer setMasksToBounds:YES];
[registerButton.layer setCornerRadius:5.0];
[registerButton setBackgroundColor:[UIColor brownColor]];
[registerButton setTitle:@"注冊" forState:UIControlStateNormal];
[registerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[registerButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
[registerButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[registerButton addTarget:self action:@selector(registerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[footerView addSubview:registerButton]; NSDictionary *constraintsView = NSDictionaryOfVariableBindings(loginButton,registerButton); [footerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-15-[loginButton]-15-|" options:0 metrics:nil views:constraintsView ]];
[footerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-20-[loginButton]" options:0 metrics:nil views:constraintsView ]]; [footerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-15-[registerButton(==loginButton)]-15-|" options:0 metrics:nil views:constraintsView ]];
[footerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[loginButton]-30-[registerButton(==loginButton)]-20-|" options:0 metrics:nil views:constraintsView]]; return footerView;
}
else
{
return nil;
}
}
郝萌主倾心贡献。尊重作者的劳动成果,请勿转载。
假设文章对您有所帮助,欢迎给作者捐赠,支持郝萌主。捐赠数额任意,重在心意^_^
我要捐赠: 点击捐赠
Cocos2d-X源代码下载:点我传送
iOS UITableView的Section Footer加入button的更多相关文章
- IOS UITableView Group&Section
UItableView 根据数据结构不同 会有不同样式 关键在两个代理 tableviewdelegate&tabledatasourse 下面代码是我实施的Group 在模拟器中 ios6. ...
- IOS UITableView NSIndexPath属性讲解
IOS UITableView NSIndexPath属性讲解 查看UITableView的帮助文档我们会注意到UITableView有两个Delegate分别为:dataSource和deleg ...
- iOS UITableView左滑操作功能的实现(iOS8-11)
WeTest 导读 本文主要是介绍下iOS 11系统及iOS 11之前的系统在实现左滑操作功能上的区别,及如何自定义左滑的标题颜色.字体大小. 一.左滑操作功能实现 1.如果左滑的时候只有一个操作按钮 ...
- 下拉刷新和UITableView的section headerView冲突的原因分析与解决方案
UITableView:下拉刷新和上拉加载更多 [转载请注明出处] 本文将说明具有多个section的UITableView在使用下拉刷新机制时会遇到的问题及其解决方案. 工程地址在帖子最下方,只需要 ...
- iOS UITableView划动删除的实现
标签:划动删除 iphone 滑动删除 ios UITableView 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://rainb ...
- iOS UITableView制作类似QQ好友列表视图
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDele ...
- 快速设置UITableView不同section对应于不同种类的cell
快速设置UITableView不同section对应于不同种类的cell 本文主要是为了写明如何在UITableView中,一个section对应于一种类型的cell,写起来不凌乱. 在不封装任何类的 ...
- iOS UITableView Tips(2)
#TableView Tips(2) (本来想一章就结束TableView Tips,但是发现自己还是太天真了~too young,too simple) ##架构上的优化 在Tips(1)中指出了一 ...
- iOS UITableView中关于cell里的按钮被点击时如何确定是哪一个section
在section=10:row=1:的UITableView中,每一个cell都带有一个按钮,例如如下的图片一样每一个cell中都有一个“进入店铺的按钮”,但是如果我点击相应的cell要进入对应的店铺 ...
随机推荐
- webdynpro 调用应用程序做跳转
1.是调用指的是调用生成应用程序,非webdynpro组件程序, 如下: 1)调用页面,并传值 METHOD get_zgmtpage . DATA:lw_application_name TYPE ...
- cryptography
密码关还是有很多变态的题的,整理一下力所能及的吧. Circular Crypto(Asis-CTF2013) 这题只给了一张图片 仔细看一下就知道,这是几个单独的环,把它们分别整理出来.因为看着眼花 ...
- 把HTML5网页封装成APP,APK的方法
phonegap appcan HBuilder的native.js 推荐你用两个东西打包 一个是ionic,一个是hbuilder,Maven,apicloud http://mobi ...
- 经常使用MD5算法代码
经常使用的MD5算法代码日期: 2014年8月4日作者: 铁锚 MD5,全称为 Message Digest Algorithm 5(消息摘要算法第五版).详情请參考 维基百科:MD5 MD5加密后 ...
- Swift - 使用表格组件(UITableView)实现单列表
1,样例说明: (1)列表内容从Controls.plist文件中读取,类型为Array. (2)点击列表项会弹出消息框显示该项信息. (3)按住列表项向左滑动,会出现删除按钮.点击删除即可删除该项. ...
- ThinkPhp学习10
原文:ThinkPhp学习10 查询操作 Action模块 User下的search public function search(){ //判断username是否已经传入,且不为空 if(isse ...
- Common lisp菜鸟指南(译)
Common lisp菜鸟指南(译) Common lisp菜鸟指南(译)
- 一段代码让你秒懂java方法究竟是传值还是传地址
先看看代码以及执行结果: 凝视写得非常清楚了.我就不多说了. 我说说我的结论.事实上在java中没有传值还是传址的概念,java仅仅有引用的概念.引用类似传址.只是是一个变量名中保存着对象的地址,地址 ...
- Python heapq 模块的实现 - A Geek's Page
Python heapq 模块的实现 - A Geek's Page Python heapq 模块的实现
- MinGW MinGW-w64 TDM-GCC等工具链之间的差别与联系
不当之处,尽请指正. 同样点: 一. 他们都是用于编译生成Windows应用程序的工具链. 二. 他们都是基于gcc的. 不同之处(仅仅说大的): 一.项目之间的关系 1. MinGW应该是最先诞生的 ...