iOS开发学习笔记 UITableview
来源:互联网 发布:mac鼠标滚轮方向 编辑:程序博客网 时间:2024/05/18 04:52
预备
1.工程勾选支持ARC
2.利用IB拖一个UITableview并且连接委托
代码
用UITableview实现简单的文字和图片显示
#import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (strong,nonatomic) IBOutlet UITableView *mtableview; @property (strong,nonatomic) NSArray *list; //存储列表数据 @end
#import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize mtableview,list; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSArray *array = [[NSArray alloc]initWithObjects:@"NO.1",@"NO.2",@"NO.3",@"NO.4",@"NO.5",@"NO.6", nil]; list = array; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } //数据源委托 //tableView一共有多少行数据 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [list count]; } //每行数据的内容 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *tableViewIdentifier = @"tableViewIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:tableViewIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:tableViewIdentifier]; } NSUInteger row = [indexPath row]; cell.textLabel.text = [list objectAtIndex:row]; //添加图片 UIImage *image = [UIImage imageNamed:@"1.png"]; [cell.imageView setImage:image]; return cell; } @end
效果图
如有错误、疑问或者任何不合理的地方,请指教。谢谢。
- iOS开发学习笔记 UITableview
- iOS开发学习笔记——UITableview
- IOS UITableView 学习笔记
- iOS 学习笔记 uitableView
- 开发学习笔记--UItableView
- iOS开发学习笔记——表格1(UITableView)
- 转发iOS UITableView学习笔记
- iOS学习笔记03-UITableView
- iOS开发学习之UITableView
- ios学习临时笔记-UITableView学习
- IOS学习笔记(十一)之IOS开发之表视图(UITableView)的基本介绍(一)
- IOS学习笔记(十一)之IOS开发之表视图(UITableView)的基本介绍(一)
- IOS学习笔记(十二)之IOS开发之表视图(UITableView)的讲解与使用(二)
- IOS学习笔记(十一)之IOS开发之表视图(UITableView)的基本介绍(一)
- iOS开发笔记--UITableView入门
- iOS开发笔记之UITableView的使用
- IOS开发笔记30-UITableView(1)
- IOS开发笔记31-UITableView(2)
- android Notification 的使用
- 知识点累积
- 2006 年百度之星程序设计大赛初赛题目 6 百度语言翻译机
- php5.4.13支持GD库和freetype
- [Android studio] Android studio win 安装于初步使用
- iOS开发学习笔记 UITableview
- 关于hive语句执行时的map个数
- 肖锰:如何提高自己的编程能力----给大学生的一点建议
- Android Studio打不开的问题
- 创业者如何转型公司,3套空手套白狼的秘招
- 《大话数据结构》笔记之 第二章 算法
- js中常用方法以及document.readyState 判断页面是否加载完成 complete和interactive
- 2006 年百度之星程序设计大赛初赛题目 6 百度语言翻译机
- 琐碎小知识点