Post

Replies

Boosts

Views

Activity

Reply to SwiftUI NavigationLink in List on iOS 14
Yes sometime cells stay highlighted for some reason. For example I found that this problem could appear if you add a padding and a background color to a list. This list for example should have the problem and the rows will stay highlighted after back is pressed. struct TestListView: View { 		var body: some View { 				NavigationView { 						List { 								NavigationLink( 										destination: Text("Detail 1"), 										label: { 												Text("Show detail 1") 										} 								) 								NavigationLink( 										destination: Text("Detail 2"), 										label: { 												Text("Show detail 2") 										} 								) 						} 						.padding(.top, 10) 						.background(Color.blue) 				} 		} } You can try to remove some of the list modifiers. If you still have the problem you can try with Introspect. https://github.com/siteline/SwiftUI-Introspect The above code could be fixed in this way: struct TestListView: View { 		 		@State private var tableView: UITableView? 		private func deselectRows() { 				if let tableView = tableView, let selectedRow = tableView.indexPathForSelectedRow { 						tableView.deselectRow(at: selectedRow, animated: true) 				} 		} 		 		var body: some View { 				NavigationView { 						List { 								NavigationLink( 										destination: Text("Detail 1").onAppear { 												deselectRows() 										}, 										label: { 												Text("Show detail 1") 										} 								) 								NavigationLink( 										destination: Text("Detail 2").onAppear { 												deselectRows() 										}, 										label: { 												Text("Show detail 2") 										} 								) 						} 						.padding(.top, 10) 						.background(Color.blue) 						.introspectTableView(customize: { tableView in 								self.tableView = tableView 						}) 				} 		} } A little bit ugly but it works.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’20
Reply to Push many views into NavigationView
Seems that this issue is only present when using a NavigationLink inside a navigation bar. If we use a NavigationLink that's inside the body then everything work correctly. In my case I need to have the button inside the navigation bar so I created an hidden NavigationLink in the body which will be activated by a button located in the navigation bar. This works: struct FirstView: View { 		var body: some View { 				NavigationView { 						Text("First view") 								.navigationBarTitle(Text("First view"), displayMode: .inline) 								.navigationBarItems(trailing: 										NavigationLink("To second", destination: SecondView()) 								) 				} 		} } struct SecondView: View { 		@State var isNavigationLinkActive = false 		var body: some View { 				VStack { 						Text("Second view") 						NavigationLink("To third", destination: ThirdView(), isActive: $isNavigationLinkActive) 								.hidden() 				} 				.navigationBarTitle(Text("Second view"), displayMode: .inline) 				.navigationBarItems(trailing: 						Button("To third", action: { 								isNavigationLinkActive = true 						}) 				) 		} } struct ThirdView: View { 		@State var isNavigationLinkActive = false 		var body: some View { 				VStack { 						Text("Third view") 						NavigationLink("To fourth", destination: FourthView(), isActive: $isNavigationLinkActive) 								.hidden() 				} 				.navigationBarTitle(Text("Third view"), displayMode: .inline) 				.navigationBarItems(trailing: 						Button("To fourth", action: { 								isNavigationLinkActive = true 						}) 				) 		} } struct FourthView: View { 		var body: some View { 				Text("Fourth view") 						.navigationBarTitle(Text("Fourth view"), displayMode: .inline) 		} }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’20
Reply to iOS 15 B2 UINavigationBar Appearance color change delayed/Pop in when pushing a new viewcontroller
Please note that this is causing issues also if you have a controller with a large title and you push a controller that does not have a large title (navigationItem.largeTitleDisplayMode = .never). In this case, during the transition, the top part of the pushed controller view is covered by the background color of the large navigation bar. When the transition ends, the top part suddenly become visible again (see below image). I think that the problem is that during the transition the navigation bar height is not animated between the two states (the large title height and the compact height). On iOS 13 and iOS 14 there is a smooth animation between the two heights. I filled the bug report number FB9290717 and included a sample project that show this issue.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’21
Reply to App freezes sporadically on Lauch Screen
I'm starting to have this problem too with some users of my app. As in the case of reported by cybergen, users told me that the app remains stuck forever on the launch screen (the main storyboard is never displayed) and the entire operating system becomes difficult to use, as if the app were taking over the entire cpu. Things like displaying control center or go to home become very difficult to perform. The app is never killed by iOS and stay on the launch screen forever. Unfortunately I cannot debug this situation because I'm unable to reproduce this issue. cybergen, did you find out what the problem was? Thank you
Aug ’21
Reply to Inline or compact UIDatePicker with white tint color
Thank you for the answer andyl_. This are bad news for anyone want to develop an app with a global white tint. At this point, unfortunately, I think the only way is to revert to the old wheels type. That’s sad, I really love the new date picker style. Did someone found an alternative way to fix this issue?
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’21
Reply to Diffable data source with fetched result controller on iOS 15
Thank you Frameworks Engineer for the clarification. Just one last question for you if I can. Diffable data source with fetched result controller is using NSManagedObjectID's to check which items need to be added / removed / updated. When we are creating a new entitiy, for example: let newEntry = Entry(context: managedObjectContext) the object has a temporary id's until the store is saved. If we create a new object, we save the store and then we create another object (and we save the store) the diffable data source will see the new created item BUT also an edit on the previous object (because the NSManagedObjectID after the save has been transformed to permanent). This is causing weird animations on a table view controller (insert + update animation instead of just an insert animation). Please note that this behaviour is only present if you save the store right after you created the new entity. The only way I found to fix this is to call obtainPermanentIDs right after I created the new Core Data object, like so: let newEntry = Entry(context: managedObjectContext) try? managedObjectContext.obtainPermanentIDs(for: [newEntry]) try? managedObjectContext.save() This is forcing Core Data to set the permanent id on the just created object. Is this the correct thing to do? When using diffable data sources in combination with a fetched result controller we always need to manually call obtainPermanentIDs after creating a new entity? Thank you
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’21
Reply to Inset grouped table cells not aligned with large title
Frameworks Engineer's answer put me on the right track to find a fix. The problem actually appears to be the value returned by layoutMargins. On an iPhone 12 and on an iPhone 8 the distance between the edge of the device and the large title is the same (16px). The problem is that the value returned by layoutMargins.left is different on the two devices. On the iPhone 8 is 16px (the correct value to align the cells with the title) while on the iPhone 12 is 20px (4 pixels too much, causing the misalignment). I tried to manually set the layoutMargins property and discovered that for some reason if you set the layoutMargins to zero then the issue disappears. After settings layoutMargins to zero then layoutMargins.left will return 16px on both devices, making a perfect alignment. override func viewDidLoad() { super.viewDidLoad()    tableView.layoutMargins = .zero }
Topic: UI Frameworks SubTopic: UIKit Tags:
Jan ’22
Reply to PHCloudIdentifier without photo library access prompt
Thank you for the answer.  I’m developing a CoreData application that allow the user to store data and pictures. The app is doing some local backups of the CoreData store. Since pictures can make the store very large I just backup the data of the store without the pictures (I keep only the assetIdentifier).  If for some reason the user need to restore the data from a backup, the app will try to look for the original pictures in the user library using the asset identifiers. This is working fine if the user is restoring the data on the same device, but if the backup is restored on another device the local identifiers become useless. The idea was to also store the cloud identifier so that the restore procedure has a chance to find the original pictures also on a different device.  Now, I really don’t want to ask user to grant library access during the normal use of the app. Access will be requested only in the rare case that a restore is required. Personally, I would love to receive the cloud identifier directly inside the PHPickerResult like the assetIdentifier.  What do you think about it?
Topic: UI Frameworks SubTopic: UIKit Tags:
Jan ’22