We have a very strange issue that I am trying to solve or find the best practice for.
We have a SwiftUI View that uses the Camera to preview. So as suggested in Apples Docs we check authorisation status and then if it's not determined we request authorisation.
We also have the privacy entry in the info.plist
case .notDetermined:
AVCaptureDevice.requestAccess(for: .video) { accessStatusAuthorised in
if !accessStatusAuthorised {
self.cameraStatus = .notAuthorised
} else {
self.isAuthorized = true
self.cameraStatus = .authorised
self.startCameraSession(cameraPosition: cameraPosition)
}
}
case .restricted:
cameraStatus = .notAuthorised
isAuthorized = false
case .denied:
cameraStatus = .notAuthorised
isAuthorized = false
case .authorized:
cameraStatus = .authorised
isAuthorized = true
startCameraSession(cameraPosition: cameraPosition)
break
@unknown default:
isAuthorized = true
cameraStatus = .notAuthorised
}
However when we call this code it freezes the Camera feed, even when allow has been tapped.
However and this is the confusing part.
If we do not call the code above, we still get the permission for camera access pop up and the camera works fine after allowing.
What im concerned about is changing the code to do this and its a possible apple bug that gets fixed and hey then none of the Apps allow the camera function.
I cannot see any where that the process has changed for iOS 26 / Xcode 26.
Can anyone shed any light on this or had similar experience ?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have a project that uses the new SwiftUI Map in iOS 14
I want to be able to update the location of the Map centre dynamically.
When you tap the Zoom button and then the Location Button the Map works fine and re-centers to London.
However if you just tap the location button it re-centers to London but throws a warning about the ViewState.
I am at a loss for what is causing this issue and how to fix it.
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(
latitude: 25.7617,
longitude: 80.1918
),
span: MKCoordinateSpan(
latitudeDelta: 10,
longitudeDelta: 10
)
)
var body: some View {
VStack {
Map(coordinateRegion: $region)
Button("zoom") {
withAnimation {
region.span = MKCoordinateSpan(
latitudeDelta: 100,
longitudeDelta: 100
)
}
}
Button(action: {
withAnimation {
region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
}
}) {
Image(systemName: "location.fill")
.frame(width: 44, height: 44, alignment: .center)
.foregroundColor(.black)
.background(Color(.white))
}.buttonStyle(PlainButtonStyle())
.clipShape(Circle())
.shadow(color: .black.opacity(0.5), radius: 1.0, x: 0.0, y: 2.0)
}
}
}
The issue I am encountering is, I need to be able to create a view in SwiftUI that looks like a sentence of text but has blanks where the user can enter their own text. I also need a way to be able to capture the entered text from the binding, but not sure how to do multiple bindings in a loop.
Ive tried a few options and the closest I have got is using LazyGrid, but it doesn't look like a normal sentence due to spacing?
Any help appreciated.
struct MultiText: View {
@State var text = "There was once a {-} that only had {-} in it. How did they get in? {-}"
@State var answerText: String = "XXXXXXX"
let rows = [
GridItem(.adaptive(minimum: 80))
]
var body: some View {
GeometryReader { geo in
HStack {
LazyVGrid(columns: rows, alignment: .leading, spacing: 0) {
ForEach(text.components(separatedBy: " "), id: \.self) { component in
if component == "{-}" {
TextField("", text: $answerText
)
} else {
Text(component)
}
}
}.frame(width: geo.size.width * 0.80)
Image(systemName: "flag").frame(width: 30, height: 30)
}.frame(width: geo.size.width)
}
}
}
This produces the following result