TableView: viewForHeaderInSection: default value?

I want to have a separate title for a separate section, and the rest is the default title.

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return ???;
}

What do I need to return to just get the default header view?

+3
source share
3 answers

The default title view nil, no title!

+9
source

Well, the documentation does not say how to provide a default view. Have you tried to return nilto find out what will happen?

, ( , ):

  • BOOL ivar tableview shouldShowDefaultHeader.
  • respondsToSelector, - :
if (shouldShowDefaultHeader == YES && [NSStringFromSelector(aSelector) isEqual:@"tableView:viewForHeaderInSection:"]) { return NO; }
return [super respondsToSelector:aSelector];
  • shouldShowDefaultHeader ivar .

: , nil , . , , .:)

0

, "nil".

If you want the view to be in place, you can highlight the custom view in this method and make it return that view.

For example, if you want the image to be the title for this section, you should do something like:

[view addSubview:pictureView];

return view;

This will return this view for the section whose index you passed.

0
source

Source: https://habr.com/ru/post/1719856/


All Articles