UITableView checks if index is shown

to get the required cell height, I implemented a function such as

+(CGFloat)rowHeightForTableView:(UITableView*)tableView andObject:(NSObject*)theObject {...}

inside the cells.

Since tableView is one of the parameters, I can check if it is a simple or grouped style sheet and includes the resulting width in my calculations. But how do I check if a pointer is displayed?

+1
source share
1 answer

You can check if the table view data source responds to a selector sectionIndexTitlesForTableView:(which the data source for the indexed table view should implement):

if ([tableView.dataSource 
       respondsToSelector:@selector(sectionIndexTitlesForTableView:)])
{
    NSArray *result = 
             [tableView.dataSource sectionIndexTitlesForTableView:tableView];
    if (result != nil)
        NSLog(@"tableView is currently indexed");
    else
        NSLog(@"tableView is not currently indexed");
}
else
    NSLog(@"tableView does not implement indexing");

, , , , - ( , - ).

+2

All Articles