Hello!
Tell me how to properly launch the map and display the user's location? After reading the documentation, I didn't quite understand how to correctly implement the code.
Thank!
Post
Replies
Boosts
Views
Activity
Hello!) Tell me why the location display does not work in the simulator?And how to fix the problem?
Thanks!
import SwiftUI
import MapKit
struct ContentView: View {
@State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 34.002871, longitude: -118.157545), span: MKCoordinateSpan(latitudeDelta: 0.03, longitudeDelta: 0.03))
@State private var trackingMode = MapUserTrackingMode.follow
var body: some View {
Map(coordinateRegion: $region, interactionModes: .all, showsUserLocation: true, userTrackingMode: $trackingMode)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Hello! Can you tell me what is the best way to work with text with more than 1000 characters (application for reference)?
I have a title and body text, I use:
let text1 = "title text"
let text2 = """
						body text
						"""
and its display:
VStack {
Text (text1)
	 .modificator ()
Text (text2)
	 .modificator ()
}
How can you localize for different countries?
Or are there more correct methods for displaying large text?
Hello!
Tell me, did someone implement the method of changing the text that is used in iOS (iOS Settings - text size) Is it a slider with intermediate scaling points?
Can anyone have an example when the visual part and the working algorithm?
Thanks!
Good afternoon!
Tell me how to correctly implement a connection between different views for general object changes?
For example, there is 1 view where I use the button to change the background color, go to view 2 and there is already a changed background color and vice versa with view 2 change the color for all other views?
I tried to use "ObservableObject" but I get to change the color on one view, when I switch, the standard is restored in the next view
class Store: ObservableObject {
@Published var colorBackground = "Black"
}
View connection
@ObservedObject var store: Store
Button
Button(action: {
	self.store.colorBackground = "Black"
	}, label: {
})
Background color
ZStack {
Color(store.colorBackground)
.edgesIgnoringSafeArea(.all)
}
Good afternoon!
Can you tell me how to calculate the maximum speed of the user? Do you have an example of the implementation of the function?
And also tell me to calculate the distance traveled? Maybe someone has an example of implementation.
My application is a speedometer, used only Core Location.
Thank you!
Good afternoon!
Can you advise, I want to implement photo exposure fixing by clicking on photo preview point, at the moment I use DragGesture to get CGPoint and pass it to capture setup
let device = self.videoDeviceInput.device
do {
try device.lockForConfiguration()
if device.isFocusPointOfInterestSupported {
device.exposurePointOfInterest = focusPoint
device.exposureMode = .autoExpose
device.unlockForConfiguration()
}
}
The values are printed to the terminal, but in the preview it feels like one point closer to the bottom edge is being used.
The code for the view is:
.gesture(
DragGesture(minimumDistance: 0)
.onChanged({ value in
self.expFactor = value.location
print(expFactor)
})
.onEnded({ value in
model.exp(with: expFactor)
})
Can you tell me if anyone has already tried to implement the fixing in SwiftUI, I want it roughly like the standard camera.
Good afternoon!
Can you tell me how I can solve the problem?
In my app there are 4 color themes of the background (like in the standard Books app). In the standard mode is the status bar according to the system color scheme, which is not suitable for white background and white status bar and vice versa with black background.
At this point, the best I could think of and find is:
.onChange(of: store.colorStatusBar) { newValue in
UIApplication.shared.statusBarStyle = store.colorStatusBar
}
But Xcode writes that this code is out of date and displays a warning:
'statusBarStyle' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene instead.
I haven't found a working example with statusBarManager.
Can you tell me how to redo it or fix it?