gpt4 book ai didi

ios - tableView :viewForHeaderInSection method is ONLY called in iOS6? 是否有可能

转载 作者:行者123 更新时间:2023-11-29 12:37:42 25 4
gpt4 key购买 nike

我正在构建一个应在 iOS7 和 iOS6 上运行的应用程序。对于 iOS6 版本,我试图实现与 iOS7 版本相似的外观和感觉。

现在我想让 iOS6 上某个部分的 headerView 看起来与 iOS7 上的相似。

使用下面的方法在 iOS6 上看起来没问题。

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
if (sectionTitle == nil) {
return nil;
}

// Create label with section title
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont startProduktView_landLabelFont];
label.frame = CGRectMake(5, 6, 300, 30);
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor darkGrayColor];
label.shadowColor = [UIColor clearColor];
label.shadowOffset = CGSizeMake(0.0, 0.0);
label.text = sectionTitle;

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 21)];

[view addSubview:label];

return view;
}

但是,我现在面临的问题是,这也适用于iOS7版本。但在 iOS 7 版本中, header 应该作为标准显示。所以基本上,如果有某种方法可以在 iOS7 下完全不调用此委托(delegate)方法,那就太好了。这可能吗?

最佳答案

您不能让特定版本的 iOS 不调用您已实现的标准委托(delegate)方法。您可以检查操作系统版本,然后提供一个 OS6 或 OS7 特定类作为委托(delegate),方法的实现不同。或者,您可以只运行代码,而不必担心您正在显式创建节标题标签。

关于ios - tableView :viewForHeaderInSection method is ONLY called in iOS6? 是否有可能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25838264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com