Tag: sectionheader

ios:uitableview部分标题锚到表顶部

我试图使多个部分(如联系应用程序)表一切顺利,我已经创build自定义部分标题显示代表此部分的字符的每个部分…问题是我希望它是像联系人确切地说,标题停留在顶部,直到下一个标题崩溃,这怎么可能发生 我正在使用下面的代码(为了让你更容易弄清楚 – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return [stateIndex count]; } – (UIView *)tableView:(UITableView *)aTableView viewForHeaderInSection:(NSInteger)section { UILabel *sectionHeader = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 40)]; sectionHeader.backgroundColor = [UIColor clearColor]; sectionHeader.font = [UIFont boldSystemFontOfSize:18]; sectionHeader.textColor = [UIColor whiteColor]; sectionHeader.text = [stateIndex objectAtIndex:section]; sectionHeader.textAlignment=UITextAlignmentCenter; return sectionHeader; } //—set the index for […]

更改UITable部分backgroundColor而不丢失部分标题

我已经改变了我的tableviews部分的backgroundColor / backgroundImage。 我使用普通的tableView。 不用担心,这个代码没有问题的工作: -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *sectionView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 728, 40)] autorelease]; sectionView.backgroundColor = [UIColor greenColor]; //For using an image use this: //sectionView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"whiteBackground.png"]]; return sectionView; } 现在的问题是, 节标题不见了。 我用这个代码设置部分的标题: – (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]){ return @""; } else […]