Posts

Post marked as solved
2 Replies
4.1k Views
I'm building a project with a target of iOS 13. I know it's just a warning, but I'm trying to figure out why I'm getting this warning "Button Style Before iOS 15.0". I'm not doing anything special with the buttons in the project. However, when I first started building it the target was iOS 15. Any ideas on who I figure out what "settings" might be triggering this warning?
Posted Last updated
.
Post not yet marked as solved
0 Replies
146 Views
I currently have a UICollectionView where I'm successfully using drag and drop, except in one case. I am tracking the drag and updating a variable for the cell over which the drag location is. Once it leaves the UICollectionView view element, it simply ignores the location and leaves the variable as the last cell over which the drag passed. However, if the user drops the cell outside the UICollectionView view, it cancels the action and never fires the performDropWith (even though it continues to track the drag up until the drop). According to what I've read so far, I don't see any mention of the fact the drag/drop should be cancelled in that case. Am I possibly missing a setting or an additional method that needs to be implemented for that? I'm using Swift and the most up to date Xcode and simulators. Thanks for any ideas.
Posted Last updated
.
Post marked as solved
8 Replies
1.3k Views
I am trying to get the data I update in an entity within CoreData to save; however, I change the values and yet it doesn't save. Here's the basics of how I am doing this: var container: NSPersistentContainer! var theSettings: Settings! var collectionSize: Int let appDelegate = UIApplication.shared.delegate as! AppDelegate let context = container.viewContext theSettings = Settings.init(context: context) collectionSize = Int(theSettings.defaultSize) // This works sets the value correctly // Later when the user changes a setting I do this theSettings.defaultSize = 6 do { try appDelegate.persistentContainer.viewContext.save() } catch let error as NSError { print("Error: \(error), \(error.userInfo)") } I've checked and the persistentContainer is correctly setup in the appDelegate. However, the value goes back to the default once I leave the view. It never saves. I've checked all over and I can't see anything that I'm doing wrong. I've done a lot of iOS programming, but this is the first time I'm using CoreData. Thanks for any help you can offer.
Posted Last updated
.
Post marked as solved
14 Replies
3.4k Views
I am trying to use AutoLayout across all types of devices to have a square UICollectionView that maximizes the size of the UICollectionView based on the width/height of the screen (i.e. for Portrait the view is the width of the whole screen and the height is equal to that width; for Landscape the view is the height of the screen and the width is equal to that height).1. I am using Interface Builder in Xcode 9.22. Standard UICollectionView3. The UICollectionsView's settings for AutoLayout Constraints: Aspect Ratio with a Priority of 1000; Horizontal (Center) in Container with a Priority of 1000, Vertical (Center) in Container with a Prioerity of 1000; Top Space = 0 with a Priority of 250; Leading Space = 0 with a Priority of 250; Bottom Space = 0 with a Priority of 250; Trailing Space with a Priority of 250.When I do this, it just ignores the Aspect Ratio and does everything else.Anyone tell me what I'm doing wrong?
Posted Last updated
.
Post marked as solved
1 Replies
679 Views
I am trying to create a UIView within a UIStackView that I want to always be square regardless of device and orientation. I have seen posting that explain how others have done it (setting constraints between UIView and superview for both height and width - a required set and an optional set - along with a 1:1 aspect constraint for the UIView) , but it no longer seems to work under all instances - in particular iPad and iPhone 11s. Does anyone have any advice on how to make this happen. It seems to me to be a pretty routine thing to do. I've done it before programmatically, but I would really like to get it done within Interface Builder. Any suggestions would be greatly appreciated.
Posted Last updated
.
Post marked as solved
2 Replies
1.3k Views
I'm trying to set different background images on a UIButton based on the state. I'm currently using: firstButton.setBackgroundImage(UIImage(named: "cardButtonUnSelected"), for: .normal)         firstButton.setBackgroundImage(UIImage(named: "cardButtonSelected"), for: .selected) However, neither image shows up. If I change it to be just "setImage", the image shows up and switches on the change in state. So, I know the button exists and the images are loading correctly. It's simply not working when trying to do this with a background image. Anyone have any ideas on what I might be missing?
Posted Last updated
.
Post marked as solved
1 Replies
207 Views
I have a UICollectionView that scrolls both horizontally and vertically. I'm trying to center an item in the middle of the collection view. When I did this in Objective-C, I simply used the following code: [theCollection scrollToItemAtIndexPath:thePath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally|UICollectionViewScrollPositionCenteredVertically animated:TRUE]; However, in switching everything to Swift, this doesn't seem to work. When I do this: theCollection.scrollToItem(at: thePath, at: .centeredVertically|.centeredHorizontally , animated: true) An error occurs ('|' is not a postfix unary operator). If I try to do the scrollToItem twice, once with each direction, it only does the second one. Any ideas on how to make this happen with Swift? Thanks!
Posted Last updated
.