gpt4 book ai didi

iphone - 将 NSFetchedResultsController 与自定义 header 相结合

转载 作者:行者123 更新时间:2023-11-28 23:14:13 25 4
gpt4 key购买 nike

我想知道是否可以将 NSFetchedResultsController 与自定义 header 结合使用?

这是标准方式:

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
return [myFetchedResultsController sectionForSectionIndexTitle:title atIndex:index];

这是我要设置的内容

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{
UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 23)] autorelease];

//set the background
UIImageView* TopBarHeader = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 23)] autorelease];
[TopBarHeader setImage:[UIImage imageNamed:@"barre_separation_bg.png"]];

//set the shadow
[[TopBarHeader layer] setShadowColor:[[UIColor blackColor] CGColor]];
[[TopBarHeader layer] setShadowOffset:CGSizeMake(1.0f, 3.0f)];
[[TopBarHeader layer] setShadowOpacity:0.5f];
[[TopBarHeader layer] setShadowRadius:1.0f];


[headerView addSubview:TopBarHeader];


//set the text
UILabel *textHeader = [[[UILabel alloc] initWithFrame:CGRectMake(11, 0, 320, 20)] autorelease];
[textHeader setText:[myFetchedResultsController sectionForSectionIndexTitle:title atIndex:index]];
[textHeader setTextColor:[UIColor colorWithRed:(124/255.0) green:(132/255.0) blue:(137/255.0) alpha:1]];
[textHeader setBackgroundColor:[UIColor clearColor]];
[headerView addSubview:textHeader];

return headerView;
}

我怎样才能在这条线上工作?

  [textHeader setText:[myFetchedResultsController sectionForSectionIndexTitle:title atIndex:index]];

最佳答案

我找到了方法

[textHeader setText:[[[myFetchedResultsController sections] objectAtIndex:section] name]];

关于iphone - 将 NSFetchedResultsController 与自定义 header 相结合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7140925/

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