如何向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]; 图像下载完后,如何把站位图像更新为下载的图像 使用mailcore无法获取126邮箱的邮件列表 iOS词典应用SDK 在xcode4环境使用boost库遇到问题求助 多线程的菜鸟问题 MAC 开识别USB 程序 国内手机应用,加入google maps API和baidu maps API好?请大侠们告诉我下优缺点,谢谢啦! 去融信恒通的笔试题,求解答,大家一起讨论下 怎么将沙盒路径中的视频保存到相册啊,哪位大神会啊 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];