Post

Replies

Boosts

Views

Activity

React to pinned state of a CollectionView header
I'm in the process of rewriting a TableView as a modern CollectionView, using UICollectionLayoutListConfiguration and UICollectionViewCompositionalLayout.list together with a diffable data source. One feature of our TableView is that it has section headers that are pinned when scrolling (plain table view style). They also change their background based on whether they are currently pinned or not. This is accomplished by setting UITableViewHeaderFooterView's automaticallyUpdatesBackgroundConfiguration to false and override updateConfiguration(using:). However, I don't see a way of doing the same for a CollectionView's header. I can easily provide a header view by setting the supplementaryViewProvider of the data source, and they are sticky thanks to UICollectionLayoutListConfiguration.Appearance.plain But the header view itself is a UICollectionReusableView which does not seem to have the same mechanism as UITableViewHeaderFooterView for reacting to changes to the pinned state. Is it at all possible to accomplish this with CollectionView headers? If so, how?
1
0
226
Aug ’24
URLSession.upload does not return server response
Hello, I have a problem with uploading data via URLSession when the server responds with an error. Specifically, I upload data with URLSession.upload(for:from:delegate). The server determines that the data is too large and responds with http status 413 (Payload Too Large). However, that response is not returned by URLSession.upload. Instead, it waits until a timeout occurs and throws that as an error. The weird part is: in the simulator it works perfectly fine and the server response is returned immediately as one would expect. But on an actual device (iPhone, iOS 16.3), it always runs into the timeout. I tested this with the same data. In Xcode's console, I see an interesting message: "Connection 1: received failure notification". I do not see that message in the console when running the app in the simulator. (I tried to include more log messages but the forum software wouldn't let me). I also tried to activate network debugging via CFNETWORK_DIAGNOSTICS, but could not make much sense of it. But I do see that the server response is received almost immediately. So the response is received by the network layer, just not returned by URLSession. By the way, calling upload(for:fromFile:delegate) behaves the same way. As does using a completion handler instead of async/await. I'm at a loss because I don't think our code is wrong. And I'm completely puzzled by the fact that it works as expected in the simulator.
8
0
1.7k
Jan ’23
CGAffineTransform breaks safe area insets in iOS 14?
In our app we have a TableViewController that is vertically flipped by setting tableView.transform = CGAffineTransform(scaleX: 1, y: -1) (and the same is applied to all cells). We noticed in iOS 14, initially the layout respects the safe area as expected, but after rotating the device it does not update properly, but the same safe area insets as before are applied. So for example when opening the view in portrait and then rotating to landscape, the insets left and right are still 0 and the content is rendered outside the safe area. When looking at tableView.safeAreaInsets, you can see the values are not updated after rotating, and viewSafeAreaInsetsDidChange() does not get called. The bug can be reproduced with any transformation. This worked perfectly fine in iOS 13. Is this a bug in UIKit? Is there a workaround?
7
0
2.1k
Jan ’21