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 {
}
}
Post
Replies
Boosts
Views
Activity
I am Converting numerical string to Int numbers in my Swift Playground in Xcode.
My calculation is getting more than 26 Digits...
e.g. "4444423533331235525555555"
I am getting error nil...
How to fix this?
My code look something like this:
let ageString = "4444423533331235525555555"
let ageInt = Int(ageString)
print(ageInt ?? 0)
I am Converting numerical string to Int numbers in my Swift Playground in Xcode.
My calculation is getting more than 26 Digits...
e.g. "4444423533331235525555555"
I am getting error nil...
How to fix this?
My code look something like this:
let ageString = "4444423533331235525555555"
let ageInt = Int(ageString)
print(ageInt ?? 0)
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
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.
I have implemented UICollectionView for iOS / iPadOS and now macOSBut how efficiently I can code collection view for various mac screen/display sizes?Is there any definite threshold that I can code about? Because there are no compact or regular screen sizes...Do help me with this...
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?
Hi All,Can anybody help me out with how to implement UIPointerInteraction (Which available with iPadOS 13.4) for UICollectionView Cell?I have referred this link: developer.apple.com/documentation/uikit/pointer_interactionsI want to highlight or lift UICollectionViewCell when I mouse over it on iPad...Thanks Again...
I have created a macOS catalyst App from iPadOS in Xcode.But there is no way to enter or edit a custom bundle identifier for macOS Catalyst app in Xcode.How to do that?