Posts

Showing posts from February, 2024

cncontactviewcontroller not show navigation bar for my app iOS swift

 Problem: cncontactviewcontroller not show navigation bar for my app while navigate from my app.How to sove that? Solution:                              self . tabBarController ?. navig ationController ?. isNavigationB arHidden   =   false                               self . tabBarController ?. navigat ionController ?. pushViewControl ler (viewControllerforContact,   animated :   true ) After pop back from contact view call the hide navigation because if you used the custom navigation bar.      override   func   viewDidAppear ( _  animated:  Bool ) {           self . tabBarController ?. navigat ionController ?. isNavigationBar Hidden   =   true }

store cgpoint in userdefaults iOS swift

 Problem: I want to store CGPoint in userdefaults.How can i achieve that? Solution: You have to convert the cgpoint to string then save it in userdefaults.      //  MARK: -  set and get the Add button frame      func   getBtnBounds ()-> CGPoint ? {          if   let  obj =  self . userDefaults . object ( forKe y :  "BtnBounds" )  as ?  String  {              let  point =  NSCoder . cgPoint ( for :obj)              return  point         }  else  {              return   nil         }     }           func   setBtnBounds ( value :  CGPoint ) {          let  pointValue =  NSCoder . string ( for : value) ...

After edit swipe not closed tableView and collectionview iOS swift

 Problem: While swipe edit options in collection view or tableview open after going to edit screen it was not shown that cell is in swipe mode not closed yet while pop from the nextView.How to solve that? Solution: It's because of tableview is in edit mode itself.                             viewControl. CollView . endEditi ng ( true ) Call this method to end the editing.

UIButton image and text spacing in iOS swift

Problem:  I want to design my button as first image then one space followed by text.How to achieve that in swift? Solution:             my Button . imageEdgeInsets   =   UIEdgeInsets ( top : 0,   left : 0,   bottom : 0,   right : 5)               my Button . titleEdgeInsets   =   UIEdgeInsets ( top : 0,   left : 5,   bottom : 0,   right : 0)               my Button . setImage (my image   ,   for : . normal )               my Button . setTitle ("title" ,   for : . normal )               my Button . contentHorizontalA lignment   = . fill

Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto) - error while open camera iOS swift

 Problem: While try to open camera in my app it shows that below error. Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto .. How to solve that? Solution: Because you tried in main queue.You must  try async then it will be solved. My function to be as like below.      func   openCamera () {          let  authStatus =  AVCaptureDevice . authorizationS tatus ( for :  AVMediaType . video )          switch  (authStatus){          case  . notDetermined :              showAlert ( msg : "Camera access denied" ,  controller :  self )          case  . restricted :              showAlert ( msg :  "Camera access denied" ,  controller :  self )          case  . denied :...