如何向tableview增加cell 我新建了一个tableview想向其中增加54个cell,内容分别是:第1周、第2周、。第54周不知道该怎么写(我是新手,麻烦大侠写的详细一点)非常非常感谢!!!!!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 @interface XXXX : XXXX<UITableViewDataSource, UITableViewDelegate>@implementation XXXX初始化方法里: tableview.dataSource = self; tableview.delegate = self;下边是需要实现的UITableViewDataSource, UITableViewDelegate里的函数- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 行数;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *cellId = @"XXXX"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; if(cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; } cell.backgroundColor = [UIColor XXXXX]; cell.textLabel.text = @""; cell.textLabel.font = [UIFont systemFontOfSize:XXXX]; cell.selectionStyle = UITableViewCellSelectionStyleBlue; cell.textLabel.textAlignment = self.listTextAlignment; return cell;}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 行高;}- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 行点击事件} 把 第1周、第2周、。第54周存储到一个NSMutableArray 中NSMutableArray *array=[NSMutableArray arrayWithObjects:@"第1周",@"第2周",....,nil];在- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section中return [array count];在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 中取值NSString *title=[array objectAtIndex:indexPath.row]; 关于xcode的问题,ib无法启动纠结啊~~ 匡威案例中的技术是怎么实现的? 国内一流的移动开发论坛 按键问题,代码编译没有语法问题,可是出现了这些! 什么情况? [新人求助]哪里可以下载到xcode_3.2.5_and_ios IOS7 下 UITableView 滑动删除的问题 运行出现错误,开篇视频、音乐不能正常播放 UITableViewController 使用分组时,每个分组可以下拉展开和缩起来吗? MAC下怎么检测USB的插入和拔出? IOS虚拟机可以申请苹果测试和发布证书吗 objective-c中的代理模式哪位大虾能具体解释一下 iOS实现连接打印机,打印一段字符串
初始化方法里:
tableview.dataSource = self;
tableview.delegate = self;下边是需要实现的UITableViewDataSource, UITableViewDelegate里的函数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 行数;
}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellId = @"XXXX";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
}
cell.backgroundColor = [UIColor XXXXX];
cell.textLabel.text = @"";
cell.textLabel.font = [UIFont systemFontOfSize:XXXX];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
cell.textLabel.textAlignment = self.listTextAlignment;
return cell;
}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 行高;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
行点击事件
}
NSMutableArray *array=[NSMutableArray arrayWithObjects:@"第1周",@"第2周",....,nil];在- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section中
return [array count];在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 中取值
NSString *title=[array objectAtIndex:indexPath.row];