我有一个问题,当我向表中添加行(带动画)时,节标题不会移动。我在 viewDidLoad 中创建节标题,如下所示:
CGRect header = [self.tableView rectForHeaderInSection:0];
UILabel *label = [[UILabel alloc] initWithFrame:headerFrame];
[label setText:@"---"];
label.backgroundColor = [UIColor clearColor];
[label setFont:headerFont];
[label setTextColor:[UIColor blueColor]];
[self.tableView addSubview:label];
[label release];
我应该以不同的方式添加它们吗? (是的,我意识到这些是自定义表格标题,这就是我想要的)
我有一个用户使用选择器添加行。行的添加方式如下:
NSIndexPath* path = [NSIndexPath indexPathForRow:chan.channel_number inSection:section_number];
NSArray* row_to_add = [[NSArray alloc] initWithObjects:path , nil];
[self.tableView insertRowsAtIndexPaths:row_to_add withRowAnimation:UITableViewRowAnimationRight];
行添加得很好,但我的标题 View 没有改变。如何让我的标题重新定位?
最佳答案
您需要使用真实的标题。您可以使用委托(delegate)方法 tableView:viewForHeaderinSection: 并返回 UILabel。
关于iphone - 使用自定义节标题将行添加到 tableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7017536/