Bonjour, j'ai essayé de définir une vue personnalisée sur l'en-tête de vue de table, mais la vue personnalisée ne convient pas à l'en-tête.La vue personnalisée n'est pas adaptée à l'en-tête dans UItableview
La vue personnalisée arrive comme ci-dessous, dans cette image, la vue personnalisée est de couleur orange et la vue d'en-tête est de couleur grise.Mais je veux une vue personnalisée est pleine de vue d'en-tête.
s'il vous plaît aider.
mycode:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *sectionView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, _TableList.frame.size.width, 80)];
header = [[HeaderView alloc] initWithFrame:CGRectMake(sectionView.frame.origin.x, sectionView.frame.origin.y, sectionView.frame.size.width, sectionView.frame.size.height)];
[sectionView addSubview:header];
sectionView.tag=section;
sectionView.backgroundColor = [UIColor grayColor];
UITapGestureRecognizer *headerTapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sectionHeaderTapped:)];
[sectionView addGestureRecognizer:headerTapped];
return sectionView;
}
Je pense que vous devez utiliser autolayout pour cette – iSashok
pouvez-vous s'il vous plaît me expliquer avec un code –
Pourquoi êtes-vous en utilisant deux vues? Gardez juste headerView et définissez son cadre comme ceci - UIView * sectionView = [[UIView alloc] initWithFrame: CGRectMake (0, 0, _TableList.bounds.size.width, 80)]; –