Posts

Showing posts from July, 2023

UITableview avoid top pulling

 Problem: I want to avoid the top pulling in UITableview but bottom to top scroll wants. Solution:    func   scrollViewDidScroll ( _   scrollView:   UIScrollView ) {               if   scrollView. contentOffset . y   < 0 {                   scrollView. contentOffset . y   = 0               }           }

IQKeyboard manager add done button for particular text field also add done button action for that iOS swift

 Problem: I'm using IQKeyboard manager for keyboard appearance and done button.I want to change the done button title as cancel for some textfields also some textfields i want to be as done. I want to add action for done button for particular textfield. Solution:      func textFieldDidBeginEditing ( _ textField: UITextField ) {         IQKeyboardManager . shared . toolbarDoneBarButtonItemText = "Cancel" // you can compare the textfield here and change the title as per your requirement     } for done button action add the below code          tf .keyboardToolbar. doneBarButton.setTarget( self , action:  #selector ( doneButtonClicked ))      @objc   func   doneButtonClicked () { tf. resignFirstResponder () }

TableView top one space came in swift iOS

 Problem: I don't had added headers in tableview. But in iOS 15 it came as one small space above the tableview.In previous versions of iOS no space came it works perfectly. Solution: Add the below code in viewdidload to solve the above problem.    if   #available (iOS 15.0, *){               self . tableView . sectionHe aderTopPadding   = 0.0           }

Add shadow in tableview cell using cardView iOS swift

 Solution: Add pod specification as like below   pod  'MaterialComponents/ ShadowElevations' Then add extension of class as like below class   ShadowedView :  UIView  {    override   class   var   layerClass :  AnyClass  {      return   MDCShadowLayer . self   }    var   shadowLayer :  MDCShadowLayer  {      return   self . layer   as !  MDCShadowLayer   }    func   setDefaultElevation () {      self . shadowLayer . elevation  = .cardResting          } } Assign class to the view as   ShadowedView then apply the code as like below          shadowView . setDefaultElevati on ()

Use untrusted certificate of server api call in swift iOS

 Problem: I want to call api with untrusted certificate using alomafire swift. Solution:          if   let  cook =  Sessions (). getCookie () {              HTTPCookieStorage . shared . setCo okie (cook)         }           let  session:  Session  = {                  let  manager =  ServerTrustManager ( evaluators : [ "192.168.1.15" :  DisabledTrustEvaluator ()])                  let  configuration =  URLSessionConfiguration . af . def ault                  return   Session ( configuration : configuration,  serverTrustManager : manager)             }() Instead of af.request use session.request .... Happy coding..

sdwebimage with invalid ssl certificates iOS swift

Problem: I want to load image using sdweb for invalid ssl certificate from my server. Solution:  Instead of "Uiimage" use your placeholder image          self . appImage .sd_ setBackgroundImage(with:  URL ( string : urlString),  for : . normal , placeholderImage:  "uiimage" ,options: [ SDWebImageOptions . handleCooki es , SDWebImageOptions . allowInva lidSSLCertificates ], progress: { time, times, url  in             print( "image" ,url)         })

Dayview Limit the calender for min and max dates swift Calenderkit

 Problem: I'm using calenderkit and KDCalender in my project.I want to limit the calender with min and maxdates user can able to select. Solution:  You cannot be able to set the min and max dates in calenderkit.Instead of you can restrict the user to select the date you can limit. extension  My VC : DayViewD elegate  {      func   eventsForDate ( _  date:  Date ) -> [CalendarKit. EventDescriptor ] {          let  newDate = date. localDate ()          dateSelected ( date : newDate)          self . calenderView . setDisplayDa te (newDate)          return  []     }           func   dayView ( dayView : CalendarKit. DayView ,  didMoveTo  date:  Date ) {          if  date< Date () {              self ....

Top space came on tableview ios 15 swift

Problem:  In tableview small space came in top of the tableview.But not given in constraints.Also it came in some devices only. Solution:          if   #available (iOS 15.0, *){              self . tableView . sectionHe aderTopPadding  = 0.0         } Use the above code to remove the white space in tableview.

iOS tab bar while select one tab then not select the tab aslo slide the side menu swift

Problem: I want to create a tab bar controller with four tabs.Then after if user tabs on 4th tab then i want to open the menu also not to show the 4th tab.Instead of show the menu and previous selected as same. Solution: Add the delegate function   func   tabBarController ( _  tabBarController:  UITabBarController ,  shouldSelect  viewController:  UIViewController ) ->  Bool  {          if  viewController  is  some VC  {              menushow ( titleButton )                     return   false   // Do not switch to the side menu as a tab bar item                }                 return   true     } Also add the delegate as like below class  my VC : UITabBarController , UI TabBarControl...

Custom entry point to app without storyboard initial point Navigate from app delegate swift

Image
 Solution: In scene delegate class change the code like below      func   scene ( _  scene:  UIScene ,  willConnectTo  session:  UISceneSession ,  options  connectionOptions:  UIScene . ConnectionOptions ) {          guard   let  windowScene = (scene  as ?  UIWindowScene )  else  {  return  }          let  window =  UIWindow ( windowScene : windowScene)          let  storyboard =  UIStoryboard ( name :  "Main" ,  bundle :  nil )          let  initialViewController = storyboard. instantiateViewCont roller ( withIdentifier :  "MyVC" )         window. rootViewController  = initialViewController          self . window  = window         window. makeKeyAndVisible ...