Posts

Showing posts from 2024

Instructions integration with tab bar and cell in iOS swift

 Problem: I had integrated Instructions pod in my project.I want to integrate instructions in my project with tab bar with instructions as well as if cell available then show.Otherwise not show with cell instructions. Solution: The   below code will be used for get the frame for tab bar icons and collectionview header icon focus instructions. import  Instructions      var coachFrames:[CGRect] = []       var coachStrArray:[String] = []       //       #   MARK: - viewDidAppear       override func viewDidAppear(_ animated: Bool) {               addDemoFrames()           }       //       #   MARK: - add frames       func addDemoFrames() {               DispatchQueue.main.asyncAfter( deadline: .now() + .seconds(1), execute: {                   self.coachFrames = []                   self.coachStrArray = []                   if let topController = UIApplication. topViewController() as? TabBarVC {                       let itemCount = topController.viewControllers. count                      

SiriExtension Interaction donation failed: Error Domain=IntentsErrorDomain Code=1901 "Cannot donate interaction with intent that has no valid shortcut types iOS swift

 Problem: I had tried to integrate sirikit on my project.Interaction donation failed: Error Domain=IntentsErrorDomain Code=1901 "Cannot donate interaction with intent that has no valid shortcut types The error code shown as above while try to run.How to solve that? Solution: Try to change your parameter to lowercase in your siri intents file ,then it will works. For example If you are created parameter Create new suggestion as a hint with parameters as "Title and Description" then change that to "title and description" then it will works fine.

Change project version no in general.But not updated while try to archieve.How to resolve?

Image
 Probelm: Change project version no in general.But not updated while try to archive. It was working on some projects and not working for me to this project. Solution: You can solve it by clear the xcode derived data, clean and build the project.If not resolved then try the following. Goto info.plist then check if updated.If not then update here and try to archive it will works fine.

System data has huge data - How to remove in Mac?

 Problem: System data has huge data.How can i delete the data and recover my spaces in my mac?. I had tried to delete xcode caches and other things but i'm not able to resolve. Solution: clear the the data inside the path that not used with device id you can find from xcode->menu->window->devices and simulator-.>simulator then it will show the identifier. You can check with the below device list and find the unused old one. you can remove the old and unused simulator data in the path to delete /Users/yourMac/Library/ Developer/CoreSimulator/ Devices. Because the xcode keeps the old simulators on the above path but it's not used in the new xcode. So it has huge data with unused.You can remove all and proceed. Then the system data will be low after doing this work.

Open maps with lat,long and link based iOS swift

 Problem: I want a common function that i can handle one location object with lat,long and address.That address can have a link that copied from other apps like google maps,Apple maps and whatsapp. Also want save option that will save the location into my app local database. How to achieve all the above us. Solution: func   openMaps ( lat :   Double , long :   Double , address : String   =   "" , isSave : Bool   =   true ) {       let   addressURL =   URL ( string : address. trimStr   ??   "" )       if   let   topview =   UIApplication . topViewControlle r () {           if   (lat != 0 && long != 0) {               let   actionSheet =   UIAlertController ( title :   "" ,   message :   "" ,   preferredStyle : . actionSheet )               if   let   add = addressURL, UIApplication . share d . canOpenURL (add) {                   actionSheet. addAction ( UIAlertA ction ( title :   "Open" ,   style : . default ,   handler : { _  

iOS Launch screen came as black

 Problem: My app have launch screen and i had assigned in storyboard also configured in info.plist.But it came as black screen. Solution: If launchscreen came as black if the following situation 1.Have to check that you had a storyboard with launchscreen viewcontroller as initviewcontroller 2.Also have to check that name is configured in the info.plist file for launchscreen 3.If you are using any images in launchscreen please remove and check if the image persist the issue.

While rotate to landscape some view on top shown because of status bar custom view in swift

 Problem: while rotate to landscape some view on top shown because i had added one custom view for status bar.How to avoid that? Solution: First you have to set the tag to the view that you are added for customisation. Then follow the code.      override   open   func   viewDidLayoutSubviews () {          super . viewDidLayoutSubviews ()                  if   let  statusView =  self . view . viewWithTag (9999) {            statusView. isHidden  =  UIDevice . current . orientation . i sLandscape         }     }      override   var   prefersStatusBarHidden :  Bool  {          return   UIDevice . current . orientation . i sLandscape     } You can hide the view while from landscape then if it rotated to portrait it will automatically shown.

app to be portaraint and particular screen will be landscape swift

 Problem: I had enabled portrait and landscape in info.plist but i want to enable one screen in landscape allowed and other screens only on portrait.How to achieve that? Solution: First you must enable the both portrait and landscape in info.plist.Then add the below code in appdelegate      func   application ( _  application:  UIApplication ,  supportedInterfaceOrientations For  window:  UIWindow ?) ->  UIInterfaceOrientationMask  {          if   let  vc =  UIApplication . topViewControlle r ()  as ? my viewController  {              // Only allow portrait (standard behaviour)              print ( "landscape called" )              return  . all ;         }          print ( "portrait called" )          return  . portrait ;     } Then it will be working fine.Happy coding..

Retrive object but done want to save coredata iOS swift

  Problem: I'm having preview option for some data but if i save other data came from server the temp data also saved in my coredata. How to avoid that? Solution:      let  context  =   NSManagedObjectContext ( concurr encyType : . privateQueueConcurrencyType )     context. persistentStoreCoordin ator  =  getContext (). persistentStoreCo ordinator The above code solves my problem. Below are coredata initilisations in my appdelegate. //     MARK: -     Get the context func   getContext   () ->   NSManagedObjectContext   {       var   context:   NSManagedObjectContext ?       if   #available (iOS 10.0, *) {           context =   persistentContainer . vie wContext       }   else   {           context =   managedObjectContext       }            return   context! }       lazy   var   persistentContainer :   NSPersistentContainer   = {           let   container =   NSPersistentContainer ( name :   APP_INFO . containerName )           let   dir =   FileManager . default . containerU RL