0
![我在这里输入图片] [1]我想显示一个按钮被按下的部分。并且,我想在节标题上显示当前时间。并显示一个单元显示部分。 同时按下按钮的日期,章节标题是我不想要两个。 我首先制作了一个静态TableView。 我试图做到这个目的,动态TableView然后阅读各个网站。代码被注释掉了。 请告诉我一个代码示例。如何创建一个动态表格视图我想知道
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
//return [array count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *title = @"section";
return title;
//return [array objectAtIndex:section];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [NSString stringWithFormat:@"%@ %i", @"row", indexPath.row];
return cell;
}
-(void)addButton
{
NSDate *date = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
NSString *strTime = [[NSString alloc] initWithFormat:@"%@",[formatter stringFromDate:date]];
array = [[NSMutableArray alloc] initWithCapacity:0];
[array addObject:strTime];
[array count];
}
对不起。答案我可能会很慢,因为它已经是午夜了。 – onion
对不起。但是你的问题写得不是很好。很难理解你想知道什么。另外,如果是午夜,我猜你并不住在美国,这可能是你英语不好的原因。无论哪种方式,我都会建议以更清晰简洁的方式重新撰写您的问题。 – Josiah
一张图片可以说出千言万语,如果您可以绘制您正在尝试做的简单线框图,可能会有所帮助。 – Imran