Hey, I'm learning Instruments (Xcode 15.1), and I've encountered a situation for which I haven't found an answer yet. I have an application that loads 12 large images, with the last one taking the most space at 147MB.
Instruments on the iOS 15 simulator correctly shows 21 allocations, as in the example from the book, because the last image is split into smaller parts due to poor optimization.
But if I run the same example on the iOS 17 simulator, I have even fewer allocations than loaded images.
And my question is whether memory allocation for large images is handled differently in iOS 17, or where can I read more about it?
Post
Replies
Boosts
Views
Activity
Hello, I have an issue with formatting text in a TextField. I want to maintain formatting to two decimal places and have it respond to changes in the device's settings, as it currently does. However, I want to get rid of the problem with deleting the first character, which for some reason cannot be empty even though it should start with an empty value.
This is my code
extension Formatter {
static let numberFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.currencyCode = "GBP"
formatter.currencySymbol = ""
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
formatter.zeroSymbol = ""
return formatter
}()
}
struct HomeView: View {
@FocusState private var isFocused: Bool
@State var value: Double = 0
var body: some View {
VStack {
TextField("0.0",
value: $value,
formatter: Formatter.numberFormatter)
.focused($isFocused)
.border(.red)
.keyboardType(.decimalPad)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
if isFocused {
Spacer()
Button("Done") {
isFocused = false
}
}
}
}
}
}
}
and here is the issue gif
I found similar problems in other forums like in https://www.hackingwithswift.com/forums/swiftui/textfield-with-initial-empty-value-for-a-number/12486/15516 but unfortunately uncomment.
Hey, I can't find any official information anywhere, maybe someone stumbled upon it, but from my observation, using the #Preview macro bypasses code coverage, which means you don't have to artificially bypass it if you care about a high percentage.
Hey, I have a problem. I was using MKMapView in my app, and in the view where I had a background at the top of the screen, in the example it was Color.red, it extended all the way to the top of the screen. Now, I wanted to switch to the newer Map and I'm seeing an issue because I'm getting a navigation bar that cuts off my color as I indicated in the picture. Does anyone know why this is happening and if there's another way to achieve this?
Steps to reproduce:
Change MapView() to Map() to see difference
import SwiftUI
import MapKit
@main
struct TestAppApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
var body: some View {
NavigationStack {
ScrollView(.vertical) {
Color.red
.padding(.top, -200)
.frame(height: 200)
MapView().frame(minHeight: 300) // change this line to Map
}
.navigationTitle("Title")
.navigationBarTitleDisplayMode(.large)
}
}
}
private typealias ViewControllerRepresentable = UIViewControllerRepresentable
struct MapView: ViewControllerRepresentable {
typealias ViewController = UIViewController
class Controller: ViewController {
var mapView: MKMapView {
guard let tempView = view as? MKMapView else {
fatalError("View could not be cast as MapView.")
}
return tempView
}
override func loadView() {
let mapView = MKMapView()
view = mapView
}
}
func makeUIViewController(context: Context) -> Controller {
Controller()
}
func updateUIViewController(_ controller: Controller, context: Context) {
update(controller: controller)
}
func update(controller: Controller) {
}
}
#Preview {
ContentView()
}
I got:
I want: