Post

Replies

Boosts

Views

Activity

Reply to safe area includes notch?
Thank you for reply! I ran the code on an iPhone 14 simulator. The launch screen image overlapped the notch which indicates the issue will happen on a simulator in runtime. I have no real iPhone 14 device for now. I wonder whether the problem will happen or not on a device.
Mar ’23
Reply to "onTapGesture" interferes with segmented picker
@OOPer By default, when the picker is tapped, the corresponding option will be selected. In addition to this,I also need to execute some other codes as long as any area within picker is tapped, no matter which option is selected. In other words, I need to know which option user taps, at the mean time I also need to know user is tapping within the picker scope.
Sep ’21
Reply to A weird problem of LazyVGrid layout
It indeed works. However, the problem comes again, if I replace ".frame(maxWidth: geo.size.height*0.6, maxHeight: geo.size.height)" with ".frame(maxWidth: min(geo.size.width * 0.45, geo.size.height * 0.6), maxHeight: geo.size.height)". I'm afraid "Lazy" seems to be the real reason. The grid doesn't load every buttons conditionally. In other words, the buttons in the last row are only loaded sometimes according to the available space probably, I guess. But what's the exact condition? In this case, the space seems to be enough to display all the buttons, but the last row isn't loaded at all. Something must have happened during rotating the simulator.
Jun ’21
Reply to keyboard can't be popped up in live preview mode
I have tried 4 methods above one by one. Disabling "Connect Hardware Keyboard" seems only to affect the behavior of simulators, but not the canvas. I switch to different simulators, including iPhone & iPad. But the problem is still there. I add a brand new swiftui view and make it to be the simplest codes. But it is still no go. struct TextFieldPopupView: View {     @State private var text = ""     var body: some View {         TextField("Hello", text: $text)             .textFieldStyle(RoundedBorderTextFieldStyle())     } } struct TextFieldPopupView_Previews: PreviewProvider {     static var previews: some View {         TextFieldPopupView()     } } Removing derived data and restarting has no effect yet. Thank you all the same.
Jun ’21
Reply to Read image from asset catalog
I'm writing a little app which will present some HD images. I need to keep the memory from spiking up. I fall back on ImageIO which needs images' data or url as input parameters. If choose "url", I have not yet found a way to get urls of images in assets catalog. I don't want to put images in main bundle directly either. Therefore, it seems like I have to choose to retrieve images' data. I try to use UIImage.jpegData(compressionQuality: ) and NSDataSet.data both. Final result is NSDataSet could save 10mb memory per image than UIImage.
Apr ’21
Reply to Read image from asset catalog
I drag a image.jpg into the assets.xcassets. Then you have added an Image Set of name image to the Asset catalogue, not Data Set. You may need to use UIImage.init(named:). Or else if you want to use NSDataAsset, you need to add a Data Set It works for me. I make a new data set, and drag the image into it. Thanks a lot. The only flaw is that it would not to provide "1x、2x、3x" options for resources like image set. :( BTW, is "UIImage(named:)" the only way to retrieve image data from image set in assets catalog? Are there other feasible methods, like by url, Data-like object, or ...? UIImage is a bit expensive for sizing and to resizing.
Apr ’21