2016年01月06日,07日,08日公司项目开发记录
来源:互联网 发布:第一财经大数据 编辑:程序博客网 时间:2024/04/28 20:33
UISwitch 控件
自定义 cell
首先现在viewDidLoad中声明这个 cell
- (void)viewDidLoad { [super viewDidLoad]; [self.tableView registerNib:[UINib nibWithNibName:@"SKUserRelativesTableViewCell" bundle:nil] forCellReuseIdentifier:@"SKUserRelatives"];}只在在代理方法中设置重用标示符-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *identifier = @"SKUserRelatives"; SKUserRelativesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (!cell) { cell = [[SKUserRelativesTableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:identifier]; } cell.textLabel.text = @"测试"; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell;}
自己创建自己的 cell
.h
#import <UIKit/UIKit.h>@interface SKUserRelativesTableViewCell : UITableViewCell{ UILabel *userName; UISwitch *switch_1; UISwitch *switch_2;}@end
.m
<span style="font-size:18px;">#import "SKUserRelativesTableViewCell.h"@interface SKUserRelativesTableViewCell ()@end@implementation SKUserRelativesTableViewCell-(void)setSelected:(BOOL)selected animated:(BOOL)animated{ [super setSelected:selected animated:animated];}-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self layoutLabel]; } return self;}-(void)layoutLabel{ userName = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, 100, 100)]; [self.contentView addSubview:userName]; switch_1 = [[UISwitch alloc]initWithFrame:CGRectMake(SKScreenWidth / 2 + 15 ,5 , 100, 100)]; [switch_1 addTarget:self action:@selector(change:) forControlEvents:(UIControlEventTouchUpInside)]; [self.contentView addSubview:switch_1]; switch_2 = [[UISwitch alloc]initWithFrame:CGRectMake(SKScreenWidth * 3 / 4 + 15,5 ,100, 100)]; [switch_2 addTarget:self action:@selector(change:) forControlEvents:(UIControlEventTouchUpInside)]; [self.contentView addSubview:switch_2];}-(void)change:(id)sender{ UISwitch *switch_BT = (UISwitch *)sender; BOOL isON = [switch_BT isOn]; if (isON) { NSLog(@"yes"); } else{ NSLog(@"no"); }}@end</span>
更多精彩文章,尽在我的公众号.
0 0
- 2016年01月06日,07日,08日公司项目开发记录
- 2016年01月07日公司项目开发记录
- 2016年01月04日公司项目开发记录
- 2016年01月12日公司项目开发记录
- 2015年12月31日公司项目开发记录
- 2016年01月07日
- ezj开发记录 7月5日
- 2月13日 mapEdit 开发记录
- 开发习惯养成记录,2010年11月3日
- 2012年11月5日 记录
- 【2014年12月29日】记录
- 2013年06月07日
- 2015年07月06日
- 2012年07月08日
- 2013年08月07日日志
- 2017年08月07日
- 2005年06月08日
- 2013年08月06日日志
- redis 常用命令
- bitnami安装redmine后修改mysql端口号
- [iOS]NSHashTable和NSMapTable用法
- iOS Runtime
- WordPress插件 UberGrid 高级相册图片分享中文插件[更新至v2.0.13]
- 2016年01月06日,07日,08日公司项目开发记录
- op03-export man pages
- FormatDataLibsvm.xls对数据的转换
- Cookie 和 Session机制详解
- iframe之嵌套方案总结
- 欢迎使用CSDN-markdown编辑器
- [已经解决]想实现限制192.168.43.1~192.168.43.255对公网的访问,请问谁用iptables或者route 能实现?
- Ofbiz之皮肤主题开发定制
- 返回数据给上一个活动