【发布时间】:2012-12-10 15:49:36
【问题描述】:
![在此处输入图像描述][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];
}
【问题讨论】:
-
对不起。我的回答可能很慢,因为已经午夜了。
-
对不起。但是你的问题写得不是很好。很难理解你想知道什么。另外,如果是午夜,我猜你不住在美国,这可能就是你英语不好的原因。无论哪种方式,我都建议以更清晰简洁的方式重新编写您的问题。
-
一张图片能说出一千个字,如果你能画一个简单的线框来说明你正在尝试做的事情,它可能会有所帮助。
标签: iphone ios xcode uitableview