Post

Replies

Boosts

Views

Activity

SwiftUI comes with wrong height when using UIHostingController inside UICollectionViewCell
I am trying to display a list of SwiftUI using UICollectionView, what I did is: using UICollectionViewCell to host the UIHostingController when the cell willDisplay, I added the UIHostingController to parent view controller remove it from parent controller when cell didEndDisplay I notice sometimes, swiftUI only shows half or less half height of cell's height, when I scroll a cell outside screen back to screen, it made me feel the swiftUI is not rendered proper when it's outside screen. code to host the UIHostingController: class MyCell: UICollectionViewCell { &#9;&#9;private lazy var widgetHostingVC: UIHostingController<AnyView> = {         let vc = UIHostingController(rootView: AnyView(Text("")))         return vc     }() &#9;&#9;/* BTW, widgetHostingVC's view is added to contentView during init, with constraints edge to edge */ } code to pass SwiftUIView to cell, called when cellForItemAt:indexPath:: func config(_ swiftUIView: AnyView) { &#9;&#9;self.widgetHostingVC.rootView = swiftUIView } code to add widgetHostingVC to parentVC, called when cell willDisplay: func addViewControllerToParentVC(_ parentVC: UIViewController) { &#9;&#9;parentVC.addChild(self.widgetHostingVC) &#9;&#9;self.widgetHostingVC.didMove(toParent: parentVC) &#9;&#9;self.contentView.addSubview(self.widgetHostingVC.view) &#9;&#9;// setup constraints } code to remove widgetHostingVC from parentVC, call when cell didEndDisplaying: func removeViewControllerFromParentVC() { &#9;&#9;self.widgetHostingVC.removeFromParent() } Anyone know what is the problem cause the swiftUI not render with correct height?
1
0
1.4k
Dec ’20
We have limit timeline updates, why all the popular widget apps in the market get update at least every minute?
I have read Widget Timelines With Clock-Based App - https://developer.apple.com/forums/thread/650293, Keeping a Widget Up To Date - https://developer.apple.com/documentation/widgetkit/keeping-a-widget-up-to-date WidgetKit won't request a new timeline at the end - https://developer.apple.com/forums/thread/653265 I learnt that WidgetKit Extension is not alive whenever the widget is visible Updating every minute is far too aggressive. Widgets have a limited number of updates and if you were to try to update every minute, you'll quickly run out of updates. But from my observation to those popular widget apps in the app store, they all manage to update widget every single minute precisely, not only the digital clock but also Analog clock. If widget is a static snapshot, not alive, we are not allowed to provide a timer, and we also have limit timeline entry to update, why these apps are working? Is there anything I missed reading, or is there anything missing from document?
2
0
7.1k
Nov ’20
Widget can't display large Text?
I am trying to show a large text on Widget, larger than .largeTitle, and I notice when the text size exceed 48, the widget shows blank screen, and it come back when I change the text size to 47. struct TestView: View {     var body: some View { &#9;&#9;&#9;&#9;Text("Hi").font(.system(size: 48)) &#9;&#9;} } struct TestView_Previews: PreviewProvider {     static var previews: some View { &#9;&#9;&#9;&#9;TestView() &#9;&#9;&#9;&#9;&#9;.previewContext(WidgetPreviewContext(family: .systemSmall)) &#9;&#9;} } The Text seems stop expending itself. Is this the limitation or I missed something?
3
0
1.5k
Oct ’20
Configurations to UIImagePickerController saving images to tmp folder
When user picked an image from photo library, using UIImagePickerController, there is a compressed version of the same image is saved at tmp folder as well, from my test, the compressed image becomes 800 KB from the original 5 MB photo. I want to have more control about those images under tmp folder, so I like to know: Do we have option to turn off saving a compressed image to tmp folder? Do we have option to set compression rate? Do we have option to change the location fromtmp folder to some other place?
0
0
431
Oct ’20
widgetURL is override inside Foreach
I am displaying 3 rows in medium size widget like below: row 1 row 2 row 3 my view structure is here: VStack { &#9;&#9;ForEach(records, id: \.id) { item in &#9;&#9;&#9;&#9;ZStack { &#9;&#9;&#9;&#9;&#9;&#9;// some views &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;.widgetURL(URL(string: "wig://\(item.id)")) &#9;&#9;} &#9;&#9;Divider() } It seems the widget URL for first and second items are override by the the third item, all deep link will open third item's content. what is the proper way to add deep link for views generated from ForEach?
4
0
1.2k
Oct ’20
How to uninstall macOS Big Sur Beta from a separate APFS volume?
My mac is using Catalina, I was following the link installing macOS Beta on a separate APFS volume - https://support.apple.com/en-us/HT208891 to install Big Sur Beta. After installation completed, I switch back to Catalina, I found the developer app installed on Catalina won't work, it crashes immediate when I open it. I tried to delete the volume that installed Big Sur Beta, but it's not working, I am still not able to open developer app. Further more, on Catalina OS Volume, there are two new volume was created: Volume with name update appears on desktop, I have no idea what it is. Volume with name disk1s7 appears on disk untilites, I cannot erase it, I cannot delete it. The question is, how to completed remove beta OS from separate APFS volume with the volume update and disk1s7?
7
0
7.2k
Jun ’20