1. #import <UIKit/UIKit.h>
  2.  
  3. @interface AppDelegate : UIResponder <UIApplicationDelegate>
  4.  
  5. @property (strong, nonatomic) UIWindow *window;
  6.  
  7. @end
  1. #import "AppDelegate.h"
  2. #import "AViewController.h"
  3.  
  4. @implementation AppDelegate
  5.  
  6. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  7. self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  8. // Override point for customization after application launch.
  9. self.window.backgroundColor = [UIColor whiteColor];
  10.  
  11. AViewController *root = [AViewController new];
  12. UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:root];
  13.  
  14. self.window.rootViewController = navi;
  15. [self.window makeKeyAndVisible];
  16. return YES;
  17. }
  18.  
  19. @end
  1. #import <UIKit/UIKit.h>
  2.  
  3. @interface AViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>
  4. {
  5. // 呈现数据源的控件
  6. UITableView *_tableView;
  7.  
  8. // 数据源
  9. NSArray *datas;
  10. }
  11. @end
  1. #import "AViewController.h"
  2. #import "CumstomCell.h"//导入自定义的cell
  3.  
  4. @implementation AViewController
  5.  
  6. -(void)loadView
  7. {
  8. [super loadView];
  9.  
  10. // 不分组的plain样式
  11. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(, , , ) style:UITableViewStylePlain];
  12. // 数据源代理
  13. _tableView.dataSource = self;
  14. _tableView.delegate = self;
  15. [self.view addSubview:_tableView];
  16. }
  17.  
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20.  
  21. NSString *str = @"A,B,C,D,E,F,G,H,I,J,K,L,M,N";
  22. datas = [str componentsSeparatedByString:@","];
  23. }
  24.  
  25. #pragma mark -数据源配置-
  26. // 配置tablview显示多少行数据
  27. -(NSInteger)tableView:(UITableView *)tableView
  28. numberOfRowsInSection:(NSInteger)section
  29. {
  30. return datas.count;
  31. }
  32.  
  33. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  34. {
  35. return 120.0f;
  36. }
  37.  
  38. // 每个cell显示什么内容
  39. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  40. {
  41. static NSString *indentity = @"cell";
  42. //使用自定义的cell
  43. CumstomCell *cell = [_tableView dequeueReusableCellWithIdentifier:indentity];
  44. if (cell == nil) {
  45. cell=[[CumstomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentity];
  46. }
  47.  
  48. //NSLog(@"%d",indexPath.row);
  49. //NSString *t = [datas objectAtIndex:indexPath.row];
  50.  
  51. //cell.textLabel.text = t;
  52. cell.imgView1.image = [UIImage imageNamed:@"123.jpg"];
  53. cell.imgView2.image = [UIImage imageNamed:@"123.jpg"];
  54. cell.imgView3.image = [UIImage imageNamed:@"123.jpg"];
  55.  
  56. return cell;
  57. }
  58.  
  59. @end
  1. #import <UIKit/UIKit.h>
  2.  
  3. @interface CumstomCell : UITableViewCell
  4.  
  5. @property(nonatomic,strong)UIImageView *imgView1;
  6. @property(nonatomic,strong)UIImageView *imgView2;
  7. @property(nonatomic,strong)UIImageView *imgView3;
  8.  
  9. @end
  1. #import "CumstomCell.h"
  2.  
  3. @implementation CumstomCell
  4. @synthesize imgView1=_imgView1;
  5. @synthesize imgView2=_imgView2;
  6. @synthesize imgView3=_imgView3;
  7.  
  8. -(void)dealloc{
  9.  
  10. /*
  11. [_imgView1 release];
  12. [_imgView2 release];
  13. [_imgView3 release];
  14. [super dealloc];
  15. */
  16.  
  17. _imgView1 = nil;
  18. _imgView2 = nil;
  19. _imgView3 = nil;
  20. }
  21. /**
  22. * 重写该方法
  23. */
  24. -(UITableViewCell *)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  25. {
  26. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  27.  
  28. self.imgView1 = [[UIImageView alloc] initWithFrame:CGRectMake(, , , )];
  29. //self.imgView1.backgroundColor = [UIColor redColor];
  30. [self.contentView addSubview:self.imgView1];
  31.  
  32. self.imgView2 = [[UIImageView alloc] initWithFrame:CGRectMake(++, , , )];
  33. //self.imgView2.backgroundColor = [UIColor redColor];
  34. [self.contentView addSubview:self.imgView2];
  35.  
  36. self.imgView3 = [[UIImageView alloc] initWithFrame:CGRectMake(+*+*, , , )];
  37. //self.imgView3.backgroundColor = [UIColor redColor];
  38. [self.contentView addSubview:self.imgView3];
  39.  
  40. }
  41.  
  42. return self;
  43. }
  44.  
  45. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  46. [super setSelected:selected animated:animated];
  47.  
  48. // Configure the view for the selected state
  49. }
  50.  
  51. @end

iOS 自定义UITableViewCell的更多相关文章

  1. ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布局

    本文转自 :http://www.cnblogs.com/wendingding/p/3761730.html ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布 ...

  2. iOS开发UI篇—使用xib自定义UItableviewcell实现一个简单的团购应用界面布局

    iOS开发UI篇—使用xib自定义UItableviewcell实现一个简单的团购应用界面布局 一.项目文件结构和plist文件 二.实现效果 三.代码示例 1.没有使用配套的类,而是直接使用xib文 ...

  3. 【转】iOS 通过xib自定义UITableViewCell【原创】

    原文网址:http://blog.it985.com/9683.html 在使用tableView的时候,如果cell的布局过于复杂,通过代码搭建的话不够直观.并且要不停的调整位置,字体什么的.这时, ...

  4. iOS学习之自定义UItableViewCell

    在项目开发中,大部分情况下我们都需要自定义UITableViewCell, 今天就重点整理一下目前自己已经学过的自定义Cell的一些注意事项; 分步骤来写吧: 1.将自定义的Cell定义为属性; 2. ...

  5. IOS开发---菜鸟学习之路--(七)-自定义UITableViewCell

    本篇将介绍如何自定义 UITableViewCell 首先选择新建文件 可以直接使用快捷键 COMMAND+n打开新建页面,然后选Objective-C class 然后选择继承之UITableVie ...

  6. 通过xib自定义UITableViewCell

    通过xib自定义UITableViewCell 一.新建iOS Application工程,选择Single View Application,不要选中Use Storyboard.假设指定的是pro ...

  7. 114自定义UITableViewCell(扩展知识:为UITableViewCell添加动画效果)

    关键操作: 效果如下: ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UITableViewCo ...

  8. IOS中UITableViewCell使用详解

    IOS中UITableViewCell使用详解 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(N ...

  9. iOS开发UITableViewCell的选中时的颜色设置(转)

    iOS开发UITableViewCell的选中时的颜色设置   1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyle ...

随机推荐

  1. ThinkPHP 模板截取字符串 【转载】

    对于英文字符可使用如下形式(模板中): {$vo.title|substr=,} 如果是中文字符thinkphp提供了msubstr,用法如下: function msubstr($str, $sta ...

  2. sql order by+字段,指定按照哪个字段来排序

    1.我们就可以使用 MySQL 的 ORDER BY 子句来设定你想按哪个字段哪中方式来进行排序,再返回搜索结果. 2.SELECT field1, field2,...fieldN table_na ...

  3. mysql没有delete操作,那是delete from操作,

    1.mysql没有delete操作,那是delete from操作, 2.DELETE FROM table_name [WHERE Clause]

  4. php获得网站根目录的几个方法

    php获得网站根目录的几个方法 电脑软硬件应用网 45IT.COM 时间:2015-01-08 12:54 作者:佚名 在php中我们要得到网站根目录可以用很多全局变量实现了,如可以利用__file_ ...

  5. Smarty 配置文件的读取

    http://www.cnblogs.com/gbyukg/archive/2012/06/12/2539067.html

  6. Strong AI Versus Weak AI

    Computer Science An Overview _J. Glenn Brookshear _11th Edition The conjecture that machines can be ...

  7. Lazarus IDE的几个小技术

    delphi+cnpack用惯了,转移到lazarus有点难受是不是!其实,lazaurs的编辑器也是蛮强大的,支持代码补全,自动完成,模板编辑,多行缩进注释,选定代码后批量更改里面的单词!目前,我知 ...

  8. 运行EFDC出现这样的错误:forrt1:severe<157>:Program Exception-access violation

    经过检查是由于TQSER出现读写错误,原来我的数据输入文件的时间是427天,后来延长到639,但其中有一个点的时间仍然维持在427.故此出现这个错误.EFDC是用Fortran编译的,通过debug才 ...

  9. C#读取shapefile文件(不用AE)

    1.创建工程文件,选窗体应用程序,命名为:EsriShpReader 2.添加SplitContainer控件到窗体 3.在SplitContainer.panel1中添加两个按钮Button,tex ...

  10. Python - 求斐波那契数列前N项之和

    n = int(input("Input N: ")) a = 0 b = 1 sum = 0 for i in range(n): sum += a a, b = b, a + ...