如何向tableview增加cell

我这个帅逼 2013-01-08 04:44:10
我新建了一个tableview

想向其中增加54个cell,内容分别是:第1周、第2周、。。。。。。。第54周

不知道该怎么写

(我是新手,麻烦大侠写的详细一点)


非常非常感谢!!!!!!!!
...全文
186 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
我这个帅逼 2013-01-09
  • 打赏
  • 举报
回复
引用 1 楼 ynb119 的回复:
@interface XXXX : XXXX<UITableViewDataSource, UITableViewDelegate> @implementation XXXX 初始化方法里: tableview.dataSource = self; tableview.delegate = self; 下边是需要实现的UITableVie……
非常感谢...很详细,受用啦
ReyZhang 2013-01-09
  • 打赏
  • 举报
回复
把 第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];
枫桦沐阳 2013-01-08
  • 打赏
  • 举报
回复
@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 { 行点击事件 }

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧