- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
TableViewController *tableViewController = [[[TableViewController alloc] init] autorelease]; //自动释放
//设置根控制器
self.window.rootViewController = tableViewController;
[self.window makeKeyAndVisible];
return YES;
}
#import "TableViewController.h"
#import "TableViewCell.h"
@interface TableViewController (){
NSMutableArray *tableData; //表格数据
}
@end
@implementation TableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//初始化表格数据
tableData = [[NSMutableArray alloc] init];
for (int i = 0; i< 10; i++) {
[tableData addObject:[NSString stringWithFormat:@"MyCellDemon%i",i]];
}
//设置row的高度为自定义cell的高度
self.tableView.rowHeight = 90;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//指定cellIdentifier为自定义的cell
static NSString *CellIdentifier = @"TableViewCell";
//自定义cell类
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
//通过xib的名称加载自定义的cell
cell = [[[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil] lastObject];
}
//添加测试数据
cell.titleLabel.text = [tableData objectAtIndex:indexPath.row];
cell.content.text = @"这是一些测试数据";
//测试图片
cell.iamge.image = [UIImage imageNamed:@"testImage.jpg"];
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
@end
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有