Search results for

swiftui

16,583 results found

Post

Replies

Boosts

Views

Activity

Can we expect support for macOS window management using a Window protocol?
The ideal workflow to manage all presentation logic would be to use swift UI without relying on storyboards. As it stands, creating a macOS application using swift UI includes a storyboard file to manage application windows. While swift UI is a HUGE step in the right direction, It's definitely lacking when it comes to macOS specific support. a sample implementation is as shown below.import SwiftUI struct WindowView : Window { var title = My window var width = 200 var height = 300 var resizeable = false var toolbar: Toolbar {} var sidebar: Sidebar {} var body: some View {} }This would be a game changer making swift UI a much more powerful addition to the ecosystem and a complete solution for UI management.Any thoughts?
0
0
392
Jun ’19
Reply to Is SwiftUI backwards compatible with iOS 12 and below?
Those are all things I can do, namely switch to Xcode 11 and Swift 5.1, and use the iOS 13 SDK. However, if the iOS 13 annotations referred to by denisoliveira are still there, then I would not be able to build for iOS 11 or 12 without having alternate UI. It is possible I could keep my current UI for the lower OSes, and just develop the new interface for iOS 13, but Apple could kick the app from the App Store in April, since I would not be fully size adaptive for the lower OS versions. It's a matter of interpretation of the new requirement, and I don't know which way Apple will decide.It's analgous to the introduction of safe areas. Those were ported so that they could be used for iOS 9 and up, even though they were introduced in the iOS 11 SDK. With the annotations restricting SwiftUI to only iOS 13, the indications are that the same treatment will not or cannot be applied to the introduction of SwiftUI. I have some dim hope that in a future beta release the annotations will be changed to
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’19
Custom button, set color when disabled
Hi I'm creating a custom Button with SwiftUI. I set the background color of the button as red.I would like that when my button is disabled (with the disabled() method), the button's background color changes to gray.What's the correct way to implement that? Is there a State property that tell that a View is disabled?Thanks for more clarifications or an example.
0
0
1.1k
Jun ’19
Measuring Computed View Size
Is there a way to measure the computed size of a view after SwiftUI runs its view rendering phase? For example, given the following view:struct MyView : View { var body: some View { Text(Hello World!) .font(.title) .foregroundColor(.white) .padding() .background(Color.red) } }With the view selected, the computed size is displayed In the preview canvas in the bottom left corner. Does anyone know of a way to get access to that size in code?
2
0
3.8k
Jun ’19
Is HSplitView or VSplitView working for anyone?
I have the following code in a file:import SwiftUI struct ContentView : View { var body: some View { HSplitView{ Text(Placeholder) Text(Placeholder) } } } #if DEBUG struct ContentView_Previews : PreviewProvider { static var previews: some View { ContentView() } } #endifAnd I get Use of unresolved identifier 'HSplitView'. Same happens with VSplitView. Does anyone else have this issue? Is it a bug in the current version?
2
0
1.4k
Jun ’19
NavigationButton and documentation questions
In the NavigationButton, what is the purpose of the isDetail parameter? If I change it to false the Landmarks app seems to look/act the same, and the documentation is muite on the subject.Speaking of documentaiton, when Swift was announced at WWDC 2014, it was released with a 400 page *book* on the subject ... does anyone know if there's going to be a SwiftUI equivalent?
1
0
920
Jun ’19
Function declares an opaque return type, but the return statements in its body do not have matching underlying types
I'm getting the following compiler error.error: function declares an opaque return type, but the return statements in its body do not have matching underlying types var body: some View { ^I'm trying to switch on some state to determine what the rest of the view hierachy looks like. How do I do this in SwiftUI? Thanks!enum Choices: Equatable, Hashable { case one case two } struct HeaderView: View { @State var choices = Choices.one var body: some View { switch choices { case .two: return ChoiceTwoView(choices: $choices) default: return ChoiceOneView(choices: $choices) } } } struct ChoiceOneView: View { @Binding var choices: Choices init(choices: Binding) { $choices = choices } var body: some View { VStack { HStack { Image(systemName: person.icloud) VStack(alignment: .leading) { Text(Person Name) .font(.headline) Text(Some long long long long long long long long text) .lineLimit(nil) .multilineTextAlignment(.leading) } } } } } struct ChoiceTwoView: View { @Binding var choices: Choices init(choices: Bind
5
0
28k
Jun ’19
How to adapt font on SwiftUI?
Want to adapt text font when using SwiftUI so that it can fit when displaying dynamic text data of various length in a navigation bar title. can't seem to find the modifier. Code is .navigationBarTitle(Text(mydata[0]) sadly this modifier does not work : .lineLimit(2) any suggestion?
0
0
622
Jun ’19
Reply to swift 5.1 & Xcode 11
Swift 5.1 comes with Xcode 11 and you have no need to touch any settings.not able to ... try new features You need macOS 10.15 Catalina to try some features supporting SwiftUI, for example, live preview or editing in Canvas does not work in macOS 10.14.Are you using Xcode 11 on macOS Catalina?
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’19
Using NSCollectionView from SwiftUI
So far it seems that in order to use NSCollectionView or NSTableView with SwiftUI, you have to wrap it all up yourself and the experience is not fluid at all.Am I missing something obvious? Did anyone do this already? If so, any tips, sample code?Thanks,Dmitry
2
0
3.5k
Jun ’19
Xcode 11: SwiftUI preview not working
I created a simple test project in Xcode 11 (on Catalina) and was able to see the previews for the SwiftUI views and their settings etc.I then opened an small established project I have and did all the updates that Xcode 11 suggested to bring it up to spec. Then I added a SwiftUI view using the SwiftUI template. Everything compiles fine, but when I attempt to see the preview of the SwiftUI view I get this error:messageRepliedWithError(Connecting to launched interactive agent 1590, Optional(Error Domain=com.apple.dt.ultraviolet.service Code=17 connectToPreviewHost: Failed to connect to 1590: Error Domain=com.apple.dt.ProcessAttachUtilities Code=3 Target process 1590 exited prematurely, likely crashed UserInfo={NSLocalizedDescription=Target process 1590 exited prematurely, likely crashed} UserInfo={NSLocalizedDescription=connectToPreviewHost: Failed to connect to 1590: Error Domain=com.apple.dt.ProcessAttachUtilities Code=3 Target process 1590 exited prematurely, likely crash
1
0
6.6k
Jun ’19
Reply to SwiftUI Light/Dark color doesn't work
Yeap, I am having the same issue. It seems SwiftUI is half-baked at the moment and I doubt it will be ready for its release. There are many things broken, and many other not implemented.I would love them to be upfront and put all the shortcomings in the release notes. Not for one minute I buy that they do not know dark color assets do not work with SwiftUI. SwiftUI is a brilliant concept and I like it, but in my view, it won't be ready until next year. I think Apple is just testing the waters, putting the framework out there. Next year, during the WWDC they will probably add and fix all the things that make the framework usuable... and as usual, we will all clap like crazy, for something that should have been there in the first place!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’19
SwiftUI: how to use NavigationView in macOS?
I have two separate Xcode projects that I'm using to learn SwiftUI:A true macOS project (not Catalyst) on Mac.An iOS project (iPhone).The following code creates a simple NavigationView with master-detail views:import SwiftUI struct ListView : View { var body: some View { NavigationView { List() { NavigationButton(destination: Text(detail 1)) { Text(row 1) } NavigationButton(destination: Text(detail 2)) { Text(row 2) } } } } } #if DEBUG struct ListView_Previews : PreviewProvider { static var previews: some View { ListView() } } #endifIt works as expected on iOS 👍But on the macOS project the same code as above doesn't work the same way When I launch the app on Mac, I get this windowAnd when I click on any row, the detail view just collapses/disappears, never showing me detail view.Any ideas how to fix this? Maybe I'm missing something? Or perhaps this is just a bug?
1
0
2.2k
Jun ’19
Reply to Using NSCollectionView from SwiftUI
Hi Dmitry,For embedding AppKit into SwiftUI the correct way form what I can currently tell is using either NSViewControllerRepresentable or NSViewRepresentable protocols.The collection view should be built with AppKit as was done before SwiftUI existed. In the case of embedding AppKit content, think of SwiftUI and just a markup language for displaying and organizing your UI instead of storyboards of nibs.I have been able to accomplish embedding of a MetalKit view using NSViewControllerRepresentable protocol just recently and it seemed to work okay (was rendering within the SwiftUI view heirarchy just fine)import Foundation import SwiftUI import AppKit struct ModelViewController : NSViewControllerRepresentable { typealias NSViewControllerType = GameViewController func makeNSViewController(context: NSViewControllerRepresentableContext) -> GameViewController { let viewController = GameViewController() return viewController } func updateNSViewController(_ nsViewCont
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’19