Post

Replies

Boosts

Views

Activity

Rearrange collection view cells within it's section
I have used UICollectionView Cells for my app. It is populated by Arrays. I have two CollectionView Sections. Section '0' & Section '1' has it's own cells populated with arrays. There are multiple cells in section 1. I want to enable user to rearrange cells within section 1. User should not be able to move cell from section 1 to section 0. I am using following code but It is giving me errors... I tried searching on the web but I didn't got the answer so I am posting it here for help... override func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { let sourceSection = sourceIndexPath.section let destSection = destinationIndexPath.section if (sourceSection destSection) { let tempInputDataArray = inputDataArray.remove(at: sourceIndexPath.item) inputDataArray.insert(tempInputDataArray, at: destinationIndexPath.item) UserDefaults.standard.set(inputDataArray, forKey: "KeyForInputDataArray") for element in inputDataArray { print(element) } } else { } }
7
0
1.8k
Apr ’21
StatusBarStyle suddenly not working in iOS / iPadOS 13, UINavigationBarController with Large Titles
I am using the following code to set the light colour for StatusBarStyle: But this code has suddenly stopped working in iOS 13 and iPadOS 13extension UINavigationController { override open var preferredStatusBarStyle: UIStatusBarStyle { get { return .lightContent } } }I have implemented UINavigationBarController with Large Titles for iOS 13 and iPadOS 13. I am using Xcode 11.4.1
1
0
1.1k
May ’20
Reset macOS Catalyst Window Size to Default Minimum Size at Every Launch
I am using following code to have a minimum size for my app, It looks something like this:#if targetEnvironment(macCatalyst) func addWindowSizeHandlerForMacOS() { UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.forEach { windowScene in print("addWindowSizeHandlerForMacOS()") windowScene.sizeRestrictions?.minimumSize = CGSize(width: 800, height: 800) // windowScene.sizeRestrictions?.maximumSize = CGSize(width: 801, height: 1101) } } #endifI want to have same minimum size as the default size for every time my mac catalyst apps opens.Every instance my app relaunch it should open in its minimum size width and height i.e. 800 by 800.
2
0
1.8k
May ’20
keyWindow?.bounds.size is nil at first load: Swift iPadOS 13
I am developing an app for iPad for iPadOS 13.There are two UICollectionViewController one navigates from one cell to another UICollectionViewController. I am using the following code:I have declared keyWindow at UICollectionView Controller as:let keyWindow = UIApplication.shared.connectedScenes .filter({$0.activationState == .foregroundActive}) .map({$0 as? UIWindowScene}) .compactMap({$0}) .first?.windows .filter({$0.isKeyWindow}).firstBut on first UICollectionViewController 'keyWindow?.bounds.size' gets printed as nil but on second UICollectionViewController same iPad Simulator 'keyWindow?.bounds.size' it gets printed as 'Optional((768.0, 1024.0))'. I am using the exact same code everywhere.func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { var sizeArea = CGSize() print("UIScreen.main.bounds.size \(UIScreen.main.bounds.size)") print(keyWindow?.bounds.size) if UIScreen.main.bounds.size == keyWindow?.bounds.size { print("UIScreen.main.bounds.size == keyWindow?.bounds.size") let spacing = self.view.frame.size.width - 25 let itemWidth = spacing / 4 sizeArea = CGSize(width: itemWidth, height: itemWidth) } else { print("else") let spacing = self.view.frame.size.width - 20 let itemWidth = spacing / 3 sizeArea = CGSize(width: itemWidth, height: itemWidth) } }What I am doing wrong here?
4
0
1.7k
Apr ’20