Posts

Document picker pdf file upload to server working in simulator but not working on real device iOS swift

 Solution: Because it had security issues for accessing the storage in real device.So follow the below code to copy the data or file to the document directory or your local variable after that upload it to the server.Then no issue will be appear. startAccessingSecurityScop edResource must be called for storage access func   documentPicker ( _  controller:  UIDocumentPickerViewController ,  didPickDocumentsAt  urls: [ URL ]) {              guard  controller. documentPickerMode  == . open ,  let  url = urls. first , url. startAccessingSecurityScop edResource ()  else  {  return  }              defer  {                 DispatchQueue. main . async  {                     url. stopAccessingSecurityScope dResource ()         ...

Select PDF file and upload to server in iOS swift || PDF picker in iOS

  Solution : In iOS we can now upload pdf files from your local device to server.Follow the below steps to achieve.. First you must have the deployment target above 14 in your app. Before you have to import the below frameworks in your project import MobileCoreServices  import UniformTypeIdentifiers Then use the below function      //     MARK: - File selection      @available ( iOS  14.0, *)      func   selectFiles () {          let  supportedTypes = [ UTType . image ,  UTType . text ,  UTType . plainText ,  UTType . utf8PlainText ,     UTType . utf16ExternalPlainText ,  UTType . utf16PlainText ,     UTType . delimitedText ,  UTType . commaSeparatedText ,     UTType . tabSeparatedText ,  UTType . utf8TabSeparatedText ,  UTType . rtf ,     UTType . pdf ,  UTType . webArchive ,...

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 }

Firebase large image upload issue in swift

 Solution: If you are not using dispatch async in firebase file upload then it will be an issue for file upload. First you have to use dispatch async in firestore.put function it will be working good

UIAlertController inside alert shows error iOS swift

 Solution:   If you had multiple  UIAlertController then it will shows error.Then follow the below step. Add extra  UIKit that will be for additional alert.                          let  alertReplace =  UIAlertController ( title :  AppTitle ,  message :  messageToshow ,  preferredStyle : . alert )                          let  okReplaceAction = UIKit. UIAlertAction ( title :  "YES" ,  style : UIKit. UIAlertAction . Style . dest ructive ) {                             UIAlertAction  in // add the action here                         }                          let  cancelReplaceAction = UIKit...

Tint color not set for asset images

Image
 Solution: You have to select the asset image and then change the settings as like above Render as -> Default to Render as -> Template image. After that you have to set the image tint color will works fine.