Post

Replies

Boosts

Views

Created

Navigation Bar and Tab Bar broken for views with ScrollView and a safe area inset containing another ScrollView
Now that's a mouthful! As of iOS 17 seed 5 and continuing into seed 6, an issue was introduced where default Navigation Bar and Tab Bar behavior breaks when a View is made up of a ScrollView with another ScrollView as the safeAreaInset. This View renders correctly using the code below, with the Navigation Bar and Tab Bar taking on a material effect when there is content behind it (screenshot 1). However, uncommenting out the ScrollView(.horizontal) so it's active causes the Nav Bar and Tab Bars to be fully transparent (screenshot 2): TabView { NavigationStack { ScrollView(.vertical) { LazyVStack { ForEach(0...100, id: \.self) { _ in Color(uiColor: UIColor.red) } } } .safeAreaInset(edge: .top, content: { //ScrollView(.horizontal) { HStack { Color.red Color.pink Color.yellow } // } .frame(maxWidth: .infinity) .frame(height: 44) }) .navigationTitle("Tab 1") .navigationBarTitleDisplayMode(.inline) }.tabItem { Label("One", systemImage: "bolt") } I have tried various combinations of the new scrollLayoutTarget() and related modifiers, but I haven’t been able to find a way to have the nav and tab bars maintain their functionality if the Horizontal ScrollView is enabled. This behavior seems like it’s supposed to be supported, because it’s one of the examples featured n this year’s WWDC session “Beyond scroll views” (at 12:34). It is also worth noting that this issue occurs whether the View is wrapped in a TabView or not. Without the TabView the problem presents the same in the Navigation Bar. I have submitted this issue as FB12983586
3
0
2.4k
Aug ’23
A couple of MusicLibraryRequest<Album> issues on Sonoma
Thanks to the MusicKit team for addressing FB12301908 and FB12301718, but I'm afraid I've discovered even more issues that make MusicLibraryRequest<Album> difficult/impossible to use on macOS. Each of these issues is occurring on Sonoma seed 7 and Xcode 15 beta 8. FB13094022 - MusicLibraryRequest crashes when no filters are applied with error about MPModelGenre The following code crashes the app when run against my library (consisting of Apple Music catalog and self-added music) on macOS or Mac Catalyst: var libraryRequest = MusicLibraryRequest<Album>.init() let albums = try! await libraryRequest.response() The error is as follows: <NSXPCConnection: 0x6000023bc460> connection to service with pid 4331 named com.apple.amp.library.framework: Exception caught during invocation of reply block to message 'performLibraryRequest:withReply:'. Exception: No identifiers for model class: MPModelGenre from source: (null) ( 0 CoreFoundation 0x000000018ebb08c0 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018e6a9eb4 objc_exception_throw + 60 2 Foundation 0x000000018fcf718c -[NSCalendarDate initWithCoder:] + 0 3 MediaPlayer 0x00000001be7f3e20 -[MPBaseEntityTranslator _objectForPropertySet:source:context:] + 392 4 MediaPlayer 0x00000001be7f41f8 -[MPBaseEntityTranslator _objectForRelationshipKey:propertySet:source:context:] + 296 5 MediaPlayer 0x00000001be7f4088 __63-[MPBaseEntityTranslator _objectForPropertySet:source:context:]_block_invoke_2 + 76 6 CoreFoundation 0x000000018eafe6f4 __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 24 7 CoreFoundation 0x000000018eafe5bc -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 268 8 MediaPlayer 0x00000001be7f3fdc __63-[MPBaseEntityTranslator _objectForPropertySet:source:context:]_block_invoke + 436 9 MediaPlayer 0x00000001be82c5c4 -[MPModelObject initWithIdentifiers:block:] + 184 10 MediaPlayer 0x00000001be7f3d80 -[MPBaseEntityTranslator _objectForPropertySet:source:context:] + 232 11 MediaPlayer 0x00000001be7f30e0 -[MPBaseEntityTranslator objectForPropertySet:source:context:] + 32 12 MediaPlayer 0x00000001be8becbc __47-[MPModeliTunesLibraryRequestOperation execute]_block_invoke + 1032 13 iTunesLibrary 0x00000001c2de3584 iTunesLibrary + 83332 14 CoreFoundation 0x000000018eb1c144 __invoking___ + 148 15 CoreFoundation 0x000000018eb1bfbc -[NSInvocation invoke] + 428 16 Foundation 0x000000018fc06698 __NSXPCCONNECTION_IS_CALLING_OUT_TO_REPLY_BLOCK__ + 16 17 Foundation 0x000000018fc04d18 -[NSXPCConnection _decodeAndInvokeReplyBlockWithEvent:sequence:replyInfo:] + 520 18 Foundation 0x000000018fc04674 __88-[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:]_block_invoke_3 + 188 19 libxpc.dylib 0x000000018e788034 _xpc_connection_reply_callout + 116 20 libxpc.dylib 0x000000018e787f2c _xpc_connection_call_reply_async + 80 21 libdispatch.dylib 0x000000010534ebcc _dispatch_client_callout3 + 20 22 libdispatch.dylib 0x0000000105373e0c _dispatch_mach_msg_async_reply_invoke + 400 23 libdispatch.dylib 0x0000000105357ae8 _dispatch_lane_serial_drain + 368 24 libdispatch.dylib 0x0000000105358e00 _dispatch_lane_invoke + 468 25 libdispatch.dylib 0x000000010536877c _dispatch_root_queue_drain_deferred_wlh + 652 26 libdispatch.dylib 0x0000000105367a54 _dispatch_workloop_worker_thread + 444 27 libsystem_pthread.dylib 0x00000001050abd9c _pthread_wqthread + 288 28 libsystem_pthread.dylib 0x00000001050b3ab4 start_wqthread + 8 ) FB13094588 - MusicLibraryRequest filtered by .title, equalTo returns blank The following code returns no results on macOS and MacCatalyst but successfully returns albums on iOS: var albumNameRequest = MusicLibraryRequest<Album>.init() albumNameRequest.filter(matching: \.title, equalTo: "The Window") let nameAlbums = try! await albumNameRequest.response() It returns no results whether I'm providing a string myself, or using the .title property of an Album I've already fetched
5
0
1k
Aug ’23
MusicLibraryRequests are much slower on macOS/Mac Catalyst than on iOS
I'm experiencing this issue on Sonoma beta 7 and Xcode 15 beta 8: FB13094612 -- MusicLibraryRequests are way slower on macOS than iOS The following code has massive speed differences on macOS than iOS, with macOS taking 3-7 seconds for each request and iOS taking 0.1 seconds or less. let start = Date() var artistAlbumRequest = MusicLibraryRequest<Album>.init() artistAlbumRequest.filter(matching: \.artistName, equalTo: "Ratboys") print("Searching artist Ratboys") let artistAlbums = try! await artistAlbumRequest.response() let name = artistAlbums.items.first!.title let id = artistAlbums.items.first!.id let end = Date() print("It took \(end.timeIntervalSince1970 - start.timeIntervalSince1970) to complete the artist request. \(artistAlbums.items.count) returned") print(artistAlbums.items) let start2 = Date() print("Searching by title: \(name)") var albumNameRequest = MusicLibraryRequest<Album>.init() albumNameRequest.filter(matching: \.title, equalTo: name) let nameAlbum = try! await albumNameRequest.response() let end2 = Date() print("It took \(end2.timeIntervalSince1970 - start2.timeIntervalSince1970) to complete this request") print(nameAlbum.items) print("Searching by ID") let start3 = Date() var albumIDRequest = MusicLibraryRequest<Album>.init() albumIDRequest.filter(matching: \.id, equalTo: id) let idalbum = try! await albumIDRequest.response() let end3 = Date() print("It took \(end3.timeIntervalSince1970 - start3.timeIntervalSince1970) to complete this request") print(idalbum.items) Awaiting the three requests takes 0.085, 0.019, and 0.102 seconds respectively on iOS. However, they take 7.10, 0.1, and 3.3 seconds on macOS. The second one only returns so quickly because of a bug where matching on title returns no results (see FB13094588) This makes it very difficult to provide a good experience when starting music playback, because it takes several seconds between the user selecting an album and it starting.
0
0
717
Aug ’23
.swipeActions with Text and Image in SwiftUI?
I'd really like to be able to show List row swipe actions with text and an image, like in Mail.app: In my app, using the .swipeActions modifier on a list row, I have been unable to display both text and an image. It just displays the image. Here is my code: .swipeActions(edge: .leading, allowsFullSwipe: true) { Button { Task { await albumProvider.treatGridAsQueue(album: album) } } label: { Label("Play", systemImage: "play.fill") } Button { AlbumContextHandler.shared.handleTag(albumObject: album, session: nil, presentedSheet: $albumProvider.sheetToPresent) } label: { Label("Tag", systemImage: "tag.fill") { } } I have also tried various initializers on Button, including init(_:systemImage:action:), but none of them have worked. The strange thing is that very occasionally just the top row of a List will display the title and label the first time the swipe actions are displayed. Showing them a second time will just show the icons, as in my screenshot. I've also played around with .buttonStyles but haven't found those to make a difference. Any ideas?
1
0
1.1k
Jan ’24
In iOS 17.4 beta 3, .searchable incorrectly presents keyboard when presenting a sheet
I've submitted this as FB13628591 but I figure a forum post never hurts ;) I’ve discovered an issue with keyboard presentation when using .searchable in SwiftUI in iOS 17.4 beta 3, shown in this video (https://imgur.com/1hmM5u0) running this sample code. struct Animal: Identifiable { var id: String { return name } let name: String } struct ContentView: View { let animals: [Animal] = [.init(name: "Dog"), .init(name: "Cat"), .init(name: "Turtle")] @State var presentedAnimal: Animal? = nil @State var searchText: String = "" var body: some View { NavigationStack { List { ForEach(animals) { item in Button(item.name) { self.presentedAnimal = item } } } .sheet(item: $presentedAnimal) { item in Text(item.name) } .searchable(text: $searchText) } } } As of iOS 17.4, the behavior of the above code is that if you tap one of the list buttons to present a sheet while the keyboard is still presented, the keyboard will dismiss then represent once the sheet is presented. In the video, I tap the “Cat” button while the search keyboard is still presented. This is confusing, because the keyboard actually belongs to the presenting .searchable view, not the presented sheet. In all previous versions, the keyboard would dismiss and stay that way. That is the correct behavior. I’ve noticed this erroneously presented keyboard does not respond to calls to resignFirstResponder: let resign = #selector(UIResponder.resignFirstResponder) UIApplication.shared.sendAction(resign, to: nil, from: nil, for: nil)
5
3
1.7k
Feb ’24