Posts

Showing posts from March, 2022

Display size of image in KB swift

 Solution:          let  size =  Double ( round (100 * image _size ) / 100)          let  sizeStr =  String ( describing :size)          messageSizeLbl . text  =  "Size: " +sizeStr+ " kb" You can use the above code to display the size of an image in kilobytes.

TableView header section disappear swift

Problem: I had tried the following code for tableview header for cell reused but sometimes the header disappears. func   tableView ( _  tableView:  UITableView ,  viewForHeaderInSection  section:  Int ) ->  UIView ? {      let  myCell =  table . dequeueReusableCell ( w ithIdentifier :  " my Cell " )  as ! my Cell        return  myCell }  Solution: You can use the below code to solve the issue. func   tableView ( _  tableView:  UITableView ,  viewForHeaderInSection  section:  Int ) ->  UIView ? {      let  myCell =  table . dequeueReusableCell ( w ithIdentifier :  " my Cell " )  as ! my Cell        return  myCell. contentView // This line changes for solving }