iOS UITableView的Section Footer添加按钮
来源:互联网 发布:js字符串contains 编辑:程序博客网 时间:2024/06/05 08:51
郝萌主倾心贡献,尊重作者的劳动成果,请勿转载。
如果文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额随意,重在心意^_^
我要捐赠: 点击捐赠
Cocos2d-X源码下载:点我传送
在处理UITableView表格时,我们希望在View底部添加按钮。
用户拖动UITableView时按钮能跟随移动。
如题,实现如下界面:
- (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源码下载:点我传送
1 0
- iOS UITableView的Section Footer添加按钮
- 在UITableView的Section Footer添加按钮
- IOS-UITableView手动添加时,Header Section的背景设置
- iOS--- UITableView 底部添加按钮
- iOS UITableView中关于cell里的按钮被点击时如何确定是哪一个section
- iOS UITableView中关于cell里的按钮被点击时如何确定是哪一个section
- iOS UITableView中关于cell里的按钮被点击时如何确定是哪一个section
- iOS UITableView:section的Header以及Footer不悬浮停留在屏幕的方法(非在scrollView代理实现的方法)
- header+section+footer(底部按钮布局)
- iOS中uitableview滑动删除添加按钮
- iOS UITableView设置Section间距
- ios 修改UITableView的section之间的距离
- 【iOS】UITableView中section的展开和收起
- iOS UITableview 刷新指定的某一个section或cell
- 【iOS】UITableView中section的展开和收起
- UITableView添加footerView按钮
- iOS UICollectionView学习之二,纯代码实现布局,纯代码实现添加Section Header头部视图和 Section Footer尾部视图
- iOS-UITableView侧滑多个按钮
- Android Path和PathMeasure类的使用之获取圆弧上的坐标值
- java之顺时钟打印矩阵
- 如何知道一个server 的ip
- java项目中使用dubbo实战
- bat命令
- iOS UITableView的Section Footer添加按钮
- 链表逆序
- 文件路径或者保存模板出现非法字符判断
- 如何获得git-repo或者android repo
- Android面试、开发之高手 编码规范与细节
- PHP单例模式例程
- Android三种设备适配
- cocos2dx Socket (一)
- Java 类型信息 instanceof、isInstance和isAssignabelFrom