I have tried to include TabView in my SwiftUI, after inclusion, I found that the bottom of the other UIView is being covered.
I have tried to use GeometryReader in each of my UIView, so that it get the maximum space. However, I found that it is still covered by the TabView unless I try to hide it. Any method to get the space only occupied by the screen (visible area, not include the tab bar at the bottom)?
Related
There are two solutions I have seen can be used to change the colour of the title bar in SwiftUI:
Making the use of NavigationView
Ignoring the sage area with .ignoresSafeArea()
I have no use for a NavigationView nor I want to use .ignoresSafeArea() since it helps on giving the TabView bottom tab space.
The only requirement to the solution I am looking for is that it cannot be for iOS 16 and above only, since it will not be viable to use in production for at least the next two years.
TL;DR:
I need to change the colour of the title bar (the upper-most part of the app) with features available in versions prior to iOS 16, and without the use of NavigationView and .ignoresSafeArea()
The white stuff in this image:
I have a two-tabbed tab view and in the second tab there are different pages being displayed. There is a navigationview and navigationlink within some of the pages. The navigation bar has a weird grey background that I can’t make go away. Any ideas how to remove that?
So it turns out I had a .padding around the view for the second tab, so everything within that view was padded, which introduced this. Removing that solved the issue.
After adding a combined gesture to a view, a TextField inside the view would no longer respond when I would tap into it to change the text. I discovered this after adding a custom combined gesture - where I used a long press to start things before dragging. (Note: things still worked if just a drag gesture was added. Not sure what is particularly different between these two cases.)
The combined gesture:
let combined = longPressGesture.simultaneously(with: dragGesture)
The gesture was added to the view with:
.gesture(combined)
I got things to work by adding an onTapGesture{} to the TextField. Didn’t have to put anything into the action. Seems like a side effect whose behavior could change in the future. Appreciate any comments on if this makes sense or other ways to handle.
TextField(“Enter Text”, text: $myText)
.textFieldStyle(RoundedBorderTextFieldStyle())
.onTapGesture {}
In case one would have this issue with a drag gesture, you can set the minimumDistance. This would still register the tap on the textfield to edit it.
DragGesture(minimumDistance: 30, coordinateSpace: .global)
Adding a drag gesture in SwiftUI to a View inside a ScrollView blocks the scrolling
I followed Apple's guide on using UIPageViewController with SwiftUI. Their guide works fine. However I ran into an issue, where if I have my PageView inside a ScrollView - the height of the PageView is no longer respected and I have to set the frame manually. Not ideal, as the content inside PageView is dynamic and thus, heights will vary.
This seems to be an issue with ScrollView; as I have another view - UIViewRepresentable - that is a simple wrapper around WKWebView - with the same issue.
Is there a way to have these views size themselves, inside a SwiftUI ScrollView?
If I place these views outside of a ScrollView and into a simple VStack for example, they size themselves correctly.
I'm stumble on two problems. I'm trying to cnstruct a view which will contain elements placed on full display of the watch (from top to bottom, full-screen). Some watch apps has such views.
Code below shows how to move content to the top+left edge of the display. And there are two problems.
var body: some View {
ZStack(alignment: .topTrailing) {
Rectangle().foregroundColor(Color.green)
HStack(spacing: 0) {
VStack(alignment: .trailing, spacing: 0) {
Text("Hello World")
.padding(.trailing, 20)
Text("Hello World")
Text("Hello World")
}
}
}.edgesIgnoringSafeArea(.all)
.navigationBarHidden(true)
}
As you can see, element Text aligned to the top+trailing with little padding.
By default on the top of display Navigation Bar with Timer are displayed. Modificator '.navigationBarHidden(true)' working and properly hides Navigation Bar, but not a Timer. This is the first problem.
I can't post the image yet.
Second problem: Two warnings are displaying in console while running the app on simulator. And i'm not sure of its meanings. Despite of the warnings simulator is is not crushed.
WatchKit Extension libMobileGestalt utility.c:421: no value found for key 1129072723
WatchKit Extension [default] has no material, defaulting to light aluminum.
My appretiations in advance.
For your first problem, you cannot remove the time from the navigation bar. The primary focus for the AW is to tell time, therefore it should always be visible. The only occasions when the time is not visible is when dictating or writing something using the swipe 'keyboard'.
Warnings are not necessarily a problem, you can ignore these (especially the second one)