- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我将一个 TableView 添加到 View Controller ,然后尝试在 IOS 6.0 中更改其节标题。
每次调用特定函数时我都会更改 header 字符串,所以我不想处理 (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
我尝试使用 (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
但是当我设置断点时,我发现它没有被调用。
在.h文件中我添加了UITableViewDelegate,UITableViewDataSource
英寸.米
-(void)viewDidAppear:(BOOL)animated
{
//tableview init
self.meetingList=[[UITableView alloc] initWithFrame:CGRectMake(10, self.ckCal.frame.origin.y + self.ckCal.bounds.size.height+20, 384, 450) style:UITableViewStylePlain];
[self.meetingList setSeparatorStyle:UITableViewCellSeparatorStyleNone];
self.meetingList.delegate=self;
//populate mutablearray for tableview here
[self eventsInThisMonth:[NSDate date]];
[self.view addSubview:self.meetingList];
}
-(void)eventsInThisMonth:(NSDate *)date
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM , yyyy"];
//self.firstSectionHeader=nil;
self.firstSectionHeader= [NSString stringWithFormat:@"Events in %@", [dateFormatter stringFromDate:date]];
NSLog(@" self.firstSectionHeader %@ ",self.firstSectionHeader);
}
#pragma Tableview
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [self.eventHeaders count] + 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 35;
}
//set header section labels
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 35)] ;
[headerView setBackgroundColor:[UIColor colorWithRed:106/256.0 green:106/256.0 blue:106/256.0 alpha:1.0]];
UILabel *subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(92, 10, tableView.bounds.size.width, 20)];
subjectLabel.textColor = [UIColor whiteColor];
subjectLabel.font = [UIFont fontWithName:@"Gill Sans" size:20];
subjectLabel.backgroundColor = [UIColor clearColor];
subjectLabel.text=self.firstSectionHeader;
NSLog(@"subjectLabel.text %@",subjectLabel.text);
if (section==0) {
//[headerView addSubview:subjectLabel];
return headerView;
}
else
return nil;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section==0) {
NSLog(@"self.firstSectionHeader in titleForHeaderInSection %@",self.firstSectionHeader);
return self.firstSectionHeader;
}
else
return nil;
}
我做错了什么?
最佳答案
我认为这可能是因为您应该只使用两者之一:viewForHeaderInSection
或 titleForHeaderInSection
。
关于ios - 未调用 UITableView titleForHeaderInSection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19249783/
我的应用程序在4.3.1模拟器中显示此内容,在5.0模拟器中显示此内容。 这是代码: - (NSString *)tableView:(UITableView *)tableView titleFor
我有一个 UITableviewController ,其标题 View 类似于: https://github.com/andersonkxiass/UITableViewHeader 但是我的表格
我像这样从 plist 加载数据到 uitableview: - (void)viewDidLoad { [super viewDidLoad]; NSArray *documentP
问题是这两个部分有时是空的,所以我不知道当它们变空时如何防止崩溃。 self.globalSections 是一个全局 NSMutableArrays,由本地两个 NSMutableArrays 存储
此应用仅供研究和学习之用。我是开发新手,所以这没什么特别的,真的。 它应该显示一个包含一些联系人的 TableView,这些联系人分为两个不同的类别:最近和 friend 但是,当我尝试使用 Titl
这是我添加的。它只是列出了每个字母字符下的所有 objectsForCharacters。 - (void)tableViewDidLoadModel:(UITableView*)tableView
所以我的问题是我的部分上方的文字太长而被截断。 有什么方法可以解决这个问题,比如让它长两行? 感谢任何帮助 最佳答案 您需要定义heightForHeaderInSection 并自定义viewFor
就调用命名我的 header 而言,我似乎无法做到正确。 如果您想知道我的模型是关于什么的 - 它基本上是一本包含美丽地点的字典,按字母顺序书写。 有人可以帮助我吗,因为我真的无法弄清楚我做错了什么?
我有一个简单的项目,它有一个 View ,这个 View 里面只包含一个 TableView 。表格 View 被分组并且有一个简单的原型(prototype)单元格。 我已经实现了 titleFor
我有如下程序:..- 但是,我想在 TitleForHeaderInSection 中按日期降序排列数据,并且还想将标题中的日期格式化为 NSDateFormatter *formatter = [[
我将一个 TableView 添加到 View Controller ,然后尝试在 IOS 6.0 中更改其节标题。 每次调用特定函数时我都会更改 header 字符串,所以我不想处理 (UIView
我有一些非常简单的代码来返回节标题的标题: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSIn
在长时间阅读和检查代码之后,我为拥有一个包含部分和部分标题的自定义表格 View 而感到自豪,所有这些都是从核心数据对象中填充的。现在我需要自定义部分标题和背景颜色。我已经看到它完成了,但是在 vie
在我的核心数据应用程序中,我使用 FetchedResultsController。通常要在 UITableView 中设置标题的标题,您将实现以下方法,如下所示: - (NSString *)tab
尝试在 tableView 的 titleForHeaderIn 部分返回复合字符串时遇到一个奇怪的问题。 如果我 NSLog 字符串,它似乎很好,但是当我返回它时,它崩溃了! 这是我的代码: - (
我用下面的代码在group tableview title header上设置标题,但是默认文本是AlignmentLeft,如何AlignmentCenter? - (NSString *)tabl
我正在使用 titleForHeaderInSection 来显示 UITableView 部分的标题。它适用于 iOS6 SDK,但 iOS7 SDK 以所有大写字母显示标题。 我猜这是 Apple
我正在尝试从 Controller 构建一个 tableView,而不仅仅是在 Storyboard中自己构建静态单元格。我的所有单元格都是从一个数组填充的,并且我希望节标题从不同的数组中显示。 nu
我有一个计算卡路里的应用程序。用户输入他们的卡路里(每一点食物都成为 TableView 中的一行。每个部分代表一天。 我有一个部分标题,添加了当天的所有卡路里。 现在我有一年的输入,加载应用程序的性
我正在使用 MRC(不要使用 ARC) 节.h @property (nonatomic, assign) NSString* headerTitle; section.m - (instancety
我是一名优秀的程序员,十分优秀!