简体   繁体   中英

How to remove Header from UITableView for particular row in iPhone?

I have a tabelview with Plain style. I have to added headers from each row. Each header should have different values. I assign the values to headers from NSMutableArray . The NSMutableArray may have null values from WebService . If the values from NSMutableArray i need to hide or remove the header for the particular row. This is my tableview design,

Header(Data)
Name:iPhone
Company : Apple
Header(Data)
Name:iPod
Company : Apple
Header(Null) // I want to remove this header from the tableview
Name:iPad
Comapany : Apple
Header(Data)
Name:iMac
Comapany : Apple

How can remove the particular header when the data is Null? Can anyone please help me? Thanks.

You can it by two ways:-

1) Set the Height of the header view 0 for the null value

 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.0;
}

2) You have to return nil from the viewForHeaderInSection method and call [myTableView reloadData]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM