简体   繁体   中英

Calculate height for empty tableview

I'm having problem in getting a height of empty tableview and my response sometimes is null and I'm storing it in array so basically my array is empty (NULL),so as we know tableview first of all calculates the height of its cell so my program is getting crash ...

{Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'}

I know this is happening because i'm calculating height when i have data in array.So as when there is no data in array i'm showing a cell from xib and i have to calculate the height of this cell also... how can I achieve this ...

You can check if the array is null

if(array){
 //return the height of the view from XIB
}else{
 //return the calculated height
}

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