#import "ListringCell.h"
@implementation ListringCell
@synthesize
_name,_time,_touxiang,_title;
-(void)dealloc{
<wbr><wbr><span style="color: #0433ff">self</span>.<span style="color: #3495af">_name</span>=<span style="color: #0433ff">nil</span>;</wbr></wbr>
<wbr><wbr><span style="color: #0433ff">self</span>.<span style="color: #3495af">_time</span>=<span style="color: #0433ff">nil</span>;</wbr></wbr>
<wbr><wbr><span style="color: #0433ff">self</span>.<span style="color: #3495af">_title</span>=<span style="color: #0433ff">nil</span>;</wbr></wbr>
<wbr><wbr></wbr></wbr> self._touxiang=nil;
<wbr><wbr> [<span style="color: #0433ff">super</span> <span style="color: #3495af">dealloc</span>];</wbr></wbr>
}
- (id)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString
*)reuseIdentifier
{
<wbr><wbr><span style="color: #0433ff">self</span> = [<span style="color: #0433ff">super</span> <span style="color: #3495af">initWithStyle</span>:style <span style="color: #3495af">reuseIdentifier</span>:reuseIdentifier];</wbr></wbr>
<wbr><wbr><span style="color: #0433ff">if</span> (<span style="color: #0433ff">self</span>) {</wbr></wbr>
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> // Initialization
code
//创建三个lable和一个imageview 并添加到cell
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> UIColor * col=[UIColor
scrollViewTexturedBackgr<wbr>oundColor<span style="color: #000000">];</span></wbr>
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _name=[[UILabel alloc]initWithFrame:CGRectMake(0,
50, 50, 20)];
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _time=[[UILabel alloc]initWithFrame:CGRectMake(50, 50, 270, 20)];
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _title=[[UILabel alloc]initWithFrame:CGRectMake(50, 0, 270, 50)];
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _touxiang=[[UIImageView alloc]initWithFrame:CGRectMake(0,
0, 50, 50)];
<wbr><wbr><wbr><wbr><span style="color: #3495af">_touxiang</span>.<span style="color: #3495af">frame</span>=<span style="color: #3495af">CGRectMake</span>(0, 0, 50, 50);</wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _time.backgroundColor=col;
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _name.backgroundColor=col;
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _title.backgroundColor=col;
<wbr><wbr><wbr><wbr><wbr><span style="color: rgb(0, 143, 0); font-family: Menlo; line-height: normal;">//name字体自适应大小
<wbr>以及居中显示</wbr></span></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr><font color="#3495AF" face="Menlo"><span style="line-height: normal;">_name</span></font><span style="color: rgb(0, 0, 0); font-family: Menlo; line-height: normal;">.</span><font color="#3495AF" face="Menlo"><span style="line-height: normal;">adjustsFontSizeToFitWidt<wbr>h</wbr></span></font>
<span style="color: rgb(0, 0, 0); font-family: Menlo; line-height: normal;">=</span>
<span style="color: rgb(4, 51, 255); font-family: Menlo; line-height: normal;">YES</span><span style="color: rgb(0, 0, 0); font-family: Menlo; line-height: normal;">;</span></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _name.textAlignment = NSTextAlignmentCenter;
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _title.textAlignment = NSTextAlignmentCenter;
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> _time.textAlignment = NSTextAlignmentCenter;
<wbr><wbr><wbr><wbr> [</wbr></wbr></wbr></wbr>self addSubview:_name];
<wbr><wbr><wbr><wbr> [</wbr></wbr></wbr></wbr>self addSubview:_time];
<wbr><wbr><wbr><wbr> [</wbr></wbr></wbr></wbr>self addSubview:_touxiang];
<wbr><wbr><wbr><wbr> [</wbr></wbr></wbr></wbr>self addSubview:_title];
<wbr><wbr><wbr><wbr> [</wbr></wbr></wbr></wbr>_title
release];
<wbr><wbr><wbr><wbr> [</wbr></wbr></wbr></wbr>_touxiang
release];
<wbr><wbr><wbr><wbr> [<span style="color: #3495af">_name</span>
<span style="color: #3495af">release</span>];</wbr></wbr></wbr></wbr>
<wbr><wbr><wbr><wbr> [<span style="color: #3495af">_time</span>
<span style="color: #3495af">release</span>];</wbr></wbr></wbr></wbr>
<wbr><wbr> }</wbr></wbr>
<wbr><wbr></wbr></wbr> return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
<wbr><wbr> [<span style="color: #0433ff">super</span> <span style="color: #3495af">setSelected</span>:selected <span style="color: #3495af">animated</span>:animated];</wbr></wbr>
<wbr><wbr></wbr></wbr> // Configure the view for the selected
state
}
- (UITableViewCell
*)tableView:(UITableView
*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
<wbr><wbr><span style="color: #0433ff">static</span> <span style="color: #3495af">NSString</span> *CellIdentifier = <span style="color: #b4261a">@"Cell"</span>;</wbr></wbr>
//用自己的自定义cell类创建cell<wbr></wbr>
<wbr><wbr></wbr></wbr> ListringCell *cell = [tableView
dequeueReusableCellWithI<wbr>dentifier<span style="color: #000000">:CellIdentifier];</span></wbr>
<wbr><wbr><span style="color: #0433ff">if</span> (cell==<span style="color: #0433ff">nil</span>) {</wbr></wbr>
<wbr><wbr><wbr><wbr> cell =[[[</wbr></wbr></wbr></wbr>ListringCell
alloc]
initWithStyle:UITableViewCellStyleDefa<wbr>ult
reuseIdentifier<span style="color: #000000">:CellIdentifier]</span>autorelease<span style="color: #000000">];</span></wbr>
<wbr><wbr> }</wbr></wbr>
<wbr><wbr></wbr></wbr> // Configure the cell...
//这里让自定义cell的lable和imageview放入自己需要放的东西
<wbr><wbr>
[cell</wbr></wbr> _name ].text=(NSString *)[[tableData objectAtIndex:[indexPath row]]objectForKey:@"nickname"];
<wbr><wbr>
[cell</wbr></wbr> _time ].text=(NSString *)[[tableData objectAtIndex:[indexPath row]]objectForKey:@"time"];
<wbr><wbr>
[cell</wbr></wbr> _title ].text=(NSString *)[[tableData objectAtIndex:[indexPath row]]objectForKey:@"title"];
<wbr><wbr>
cell.</wbr></wbr>_touxiang.image=[UIImage imageNamed:[[tableData objectAtIndex:[indexPath row]] objectForKey:@"touxiang"]];
<wbr><wbr><span style="color: #0433ff">return</span> cell;</wbr></wbr>
}
相关推荐
自定义UITableViewCell。实现各种样式的表格输入界面ios源代码设计资料
手写代码自定义UITableViewCell和xib自定义UITableViewCell的DEMO,适合初学者学习。
实现自定义UITableViewCell左滑动多菜单功能。 在同一个工作空间里面,采用了 3中实现方式: 1、使用自定义UITableViewCell + UISwipeGestureRecognizer + 代理 实现; 2、使用自定义UITableViewCell + ...
ios7自定义UITableViewCell
UITableViewCell自定义等高
ios项目源代码 各种布局控件使用及扩展视图自定义UITableViewCell等源码合集: DTCoreText-1.6.10在UITextView上实现十分丰富的文字效果 ios三级展开列表TQMultistageTableView_10802 ios个性化每个...
IOS布局控件使用自定义UITableViewCell 欢迎界面后台获取功能等项目设计IOS源码合集: ios三级展开列表TQMultistageTableView_10802 ios个性化每个tableMHNibTableViewCell ios分页的滚动视图 IOS可扩展底部TablBar ...
iPhone开发使用Xib自定义UITableViewCell
全面解析iOS应用中自定义UITableViewCell的方法共19页.pdf.zip
自定义UITableViewCell
通过自定义UITableViewCell实现ibooks的图书列表样式。
IOS源码——自定义UITableViewCell。实现各种样式的表格输入界面.7z
IOS源码——自定义UITableViewCell。实现各种样式的表格输入界面.zip
IOS应用源码之自定义UITableViewCell。实现各种样式的表格输入界面.zip
iOS 自定义UITableViewCell,iOS 自定义表视图 博客地址:http://blog.csdn.net/yang8456211
主要介绍了iOS应用开发中自定义UITableViewCell的方法,示例为传统的Obejective-C语言,需要的朋友可以参考下
因为有人问到,自己就随便写的一个小demo,模仿系统的delete,用了手势,可以实现左右滑动,点击消失,可以对单元格进行删除,但是没有用到重用,由于时间仓促,没来得及处理,希望大家见谅,自己做一下优化就可以了...
下载即可安装 支持最新ios9.1版本 一个demo 理解之后 自己可以完全自定义