Since there seems to be no direct way to create a toolbar (NSToolbar) in macOS SwiftUI, I am trying to create the toolbar on storyboard and then link it to the application. However, as expected, Xcode does not allow me to create outlets to an unlinked file, which goes into NSViewController territory. Is there a way to link a storyboard toolbar to a SwiftUI structure? If required, how does NSViewRepresentable takes a role in this?
Thank you in advance!
Related
Is there a way to use TabView using SwiftUI on WatchOS?
I've seen most of the WWDC talks and they don't mention it for WatchOS. Moreover, in the apple documentation it is not enumerated under SDK's.
Whenever I try to add it to a WatchOS project I get the following error:
'TabView' is unavailable in watchOS
Or is there a good way to replicate the desired TabView ?
I want something similar to this:
Two different pages that are changed simply by swiping horizontally.
If you want a page based navigation (swipe left/right between view controllers) in your app you simply add another WKHostingController to your project's storyboard. Connect the two hosting controllers by creating a segue between them. The segue is what determines how you navigate between controllers.
This page has a good guide on how to do it: https://www.techotopia.com/index.php/A_WatchKit_Page-based_Navigation_Tutorial
Just keep in mind that you want to add another hosting controller to the storyboard, not anything else.
I have not found a way to do this programmatically in SwiftUI, this seems like the only way to do it for now.
It's now available starting with watchOS 7: https://developer.apple.com/documentation/swiftui/tabview.
I am trying to build an app, and I want another view to open up once I click a button. I have searched for an answer, but nothing came up. I already have the button done, but I don't know how to get another view to show up. The view should be another view within the app. I am just a beginner in xCode. Thanks.
I am currently using xCode 9, and swift 4. Thanks.
You can approach this either using the storyboard or programmatically. Using the storyboard, you can ctrl-drag from the button to the other view controller and the segue will be wired up for you, like so:
If you aren't using storyboards at all, you can use the .show method of the ViewController in the button action. Apple has a good guide on segues.
I am trying to put a website in the middle of my storyboard. When I add the view controller and try to connect it to a new ViewController, I cannot control-drag the object to create the Outlet. I can create outlets for Labels and buttons, and all the rest of the normal objects. Just not for the webkit view control. It works if I try it in a new project just like it is supposed to. Is this a bug or is something in my program blocking web content?
There is no code to share since I can't get that far.
I understood your problem. Such kind of thing sometimes happen with me.
I uses a one tick to solve this problem. I copy the outlet of other control and then i rename it and change the property to my requirement.
For Example,
#IBOutlet weak var myButton: UIButton!
After then you can connect outlets to your control.
It works fine.
I am new to swift / Xcode and I am trying to create a button in Xcode that can randomly transfer to a different storyboard. I tried following the instructions in this post to do it (I also tried other ideas, but this answer was the most intuitive)
How to Segue Randomly to ViewControllers in Swift?
I've written the IBAction and connected the extra storyboards with different segues to the root view controller but when I start the simulation nothing happens when I click the "go" button. I cannot connect this button with the IBAction by a control drag, so I think that may be the problem.
I've tried creating new projects, connecting the "go" button to the root view controller, and editing the classes (it doesn't let me). What else could be wrong? My code is exactly like the answer to the link I posted. Is there a step missing to that answer?
First make sure you created a custom class for your root view controller. Also make sure you assigned your custom class to the view controller in Interface Builder.
Try dragging from your button to the view controller code pane and let XCode create the IBAction stub for you. Now touching the button should trigger your IBAction.
I would like to make a popupwindow like this:
http://www.touch-code-magazine.com/showing-a-popup-window-in-ios-class-for-download/
However, It doesn't work on my xcode because i am developing an app for ios5, using a storyboard.
Do you know any othere examples similar to this?
thanks in advance.
There is no reason you cannot create the view you need using a Nib file and then add that view pro grammatically with a VC controlled by storyboard.
Storyboards handle the kind of window you are talking about.
Make your segue "Modal", "Form Sheet", and "Default"
Then your new window make the size "Form Sheet".
This should get you something similar to what you want without resorting to NIBs.