How to add WKInterfaceTimer to SwiftUI ? Anyone who already did it ?
There is no init for WKInterfaceTimer how to do it ?
Please try:
Text(date, style: .timer)
The style .timer ensures that the text will be updated automatically.
Please note: This feature has been added to iOS 14 and watchOS 7.
Related
UPDATE: 2022-09-26
This issue has been fixed on iOS 16. Although the issue is still present on iOS 15 even when the project is compiled with the iOS 16 SDK.
Original question:
On iOS 15, the UIHostingController is adding some weird extra padding to its hosting SwiftUI view (_UIHostingView).
See screenshot below (Blue = extra space, Red = actual view’s):
Does anyone know why this happens?
I've reported this bug, Apple folks: FB9641883
PD: I have a working project reproducing the issue which I attached to the Feedback Assistant issue. If anyone wants it I can upload it too.
I found out that subclassing UIHostingController as follows fixes the issue with extra padding:
final class HostingController<Content: View>: UIHostingController<Content> {
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
view.setNeedsUpdateConstraints()
}
}
It also fixes a problem of the UIHostingController not resizing correctly when its SwiftUI View changes size.
I’ve tried to find why is this happening without luck. The only thing I’ve found to fix it is setting a height constraint to its intrinsic content size in a subclass of UIHostingController:
private var heightConstraint: NSLayoutConstraint?
override open func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 15.0, *) {
heightConstraint = view.heightAnchor.constraint(equalToConstant: view.intrinsicContentSize.height)
NSLayoutConstraint.activate([
heightConstraint!,
])
}
}
override open func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
heightConstraint?.constant = view.intrinsicContentSize.height
}
.onFocus({ isFocused in
variable = false
})
This code is not working anymore since update to 13.5 beta.
How can i achieve the same, so if a textfield is focused then....do something
I have a list in iOS 14 / Xcode 12
Im using the following/tried the following to hide the little arrows in the corner:
.listRowInsets(EdgeInsets())
.background(Color.white)
.listStyle(PlainListStyle())][1]][1]
the easiest way to remove the arrow i think is to get the NavigationLink out of the List and use the tag or isActive initialiser of NavigationLink to define whether or not the link should be activated
Hey! You need to hide the navigation link. Try This Code Below...
NavigationLink(destination: DetailView(item: yourItem)) { //Your Nav Link
EmptyView()
}.frame(width:0).opacity(0) //Hide Your Link Programmatically
I'm building my first SwiftUI app. For some reason when I command+click on an HStack the "Extract Subview" and other options don't show up. Any reason why I'm not seeing these options? I'm using Core Data and UITableView.appearance to remove lines in my List as well. Does it have to do with using core data and my use of UITableView? Couldn't find any answers after researching. Appreciate the help.
Not sure if this is an Xcode issue/bug but as of Xcode 11.4 the "Extract Subview" option (and others) show up only if the Canvas is being shown.
So, enable live preview and then cmd-click on the View you want to extract.
I got the same problem. You should do command + right click.
I was having the same problem but could not solve it with the presented solution. Came to realize that you need to have an Object embedded in another to be able to extract it.
In the example below, I would not be able to extract the HStack, but it will show up in the VStack.
struct ContentView: View {
var body: some View {
HStack(){
Image("sal")
.resizable()
.frame(width: 100, height: 100)
.aspectRatio(contentMode: .fit)
.cornerRadius(20)
.padding(.trailing)
VStack(alignment: .trailing){
Text("Camino La Angostura")
Text("2.5 Km.")
}
}
}
}
When I use both ion-footer and ion-tab at the same time with tab position as bottom. footer does not show in the app when I have both elements visible. Please advice how can I fix this?
I got answer. I have override the ionic toolbar class as follows:
.toolbar {
min-height:44px ! important;
}