Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS-在静态UITableViewController中设置节标题的样式-IOS7_Ios_Objective C_Uitableview - Fatal编程技术网

IOS-在静态UITableViewController中设置节标题的样式-IOS7

IOS-在静态UITableViewController中设置节标题的样式-IOS7,ios,objective-c,uitableview,Ios,Objective C,Uitableview,是否可以在静态UITableViewController中设置节标题背景/字体样式?我看不到任何脚本选项可以执行此操作,并且由于表是静态的,因此表方法在.M文件中已被禁用-因此我也不确定如何以编程方式应用样式设置?UITableViewDelegate协议定义了一个方法viewForHeaderInSection,该方法可在代理中实现,以返回自定义标题视图(也适用于静态UITableView)。例如: 是,为标题部分实现视图 - (UIView *)tableView:(UITableView

是否可以在静态UITableViewController中设置节标题背景/字体样式?我看不到任何脚本选项可以执行此操作,并且由于表是静态的,因此表方法在.M文件中已被禁用-因此我也不确定如何以编程方式应用样式设置?

UITableViewDelegate协议定义了一个方法viewForHeaderInSection,该方法可在代理中实现,以返回自定义标题视图(也适用于静态UITableView)。例如:


是,为标题部分实现视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    // you can get the title you statically defined in the storyboard
    NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];

    // create and return a custom view
    UILabel *customLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, 50.0f)];
    customLabel.text = sectionTitle;
    return customLabel;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    // return a custom height here if necessary
    return 50.0f;
}