I am trying to make a application that uses the standard Split View Application in Xcode, i want to be able to have multiple detail view controllers, this is all set up and it switches between the different detail view controllers fine, although when it switches it doesn't show the popup view controller button in the top left hand corner when i switch to a new page
Many Thanks for any Help
Thomas
I have fund that the reason that this may occur is because the default Xcode uiSplitView application template sets the detail view as the split view delegate so you need to either make the master view to be the delegate or make the new detail view as a delegate also.
Related
I'm sure I'm asking a simple question but I've only just started coding... so take pity on me!
I'm trying to figure out how to connect buttons (actions) to the viewController.swift from a modal/popover segue (I think the solution is the class but whenever I change it I get an error).
Eg.
In the storyboard, on the viewController interface, I have a button for sharing files. When I click it, a popover segue appears with two buttons on it, one for Fb one for Twitter, but I can't connect any actions from them to the viewController.swift
In another project I made a Google+ login and connected it to a modal segue but I couldn't make that work either.
Is segue the wrong thing to use?
Thanks for your help!
Marie
Your question would be easier to answer if you'd provide the actual error you're getting when you try to change the class.
It sounds like you're trying to connect the popover's buttons to actions in the presenting view controller (that is, the view controller that presented the popover), rather than the view controller of the popover itself. If that's the case, then that's the problem. You can only connect your buttons directly to actions available in the current scene.
This means you need a custom class for the presenting view controller (the one with the button that segues to the popover controller) and one for your popover. Set each scene view controller's classes to the appropriate custom classes you created (which must be a subclass of NSViewController or one of its subclasses or you won't be able to set the class name in IB) and you should be able to drag connections.
I'm a total newbie with xcode and swift, trying to wrap my head around ios programming.
I'm designing a storyboard for my app. The storyboard uses containers to keep track of the controls. In one of the containers resides a button. I want to create an outlet for it to add some code when it is clicked.
If the button would be on the base viewport of the storyboard, I would control-drag a blue line from the button to the source window with my UIViewController subclass file, and it would assist me in generating the code. But for some reason when the button is in a container, this just doesn't work.
When following the documentation, it says to open the assistant editor when the button is selected and it should open the relevant file. So it open an objective-c file, but when I try to control-drag into it, it informs me that I do not have write permissions. Also I feel like I should be doing it in a subclass instead.
I have searched online a lot and tried everything I can think about, but nothing has worked so far. How does this work? Can I do it programmatically or so perhaps? I hope someone can straighten out this question mark...
A container view is intended to represent an area that will host a view from a different view controller that becomes a child of the view controller that owns the container. Usually, you would create a second view controller, link your container view to it using an "embed" segue, and then put your buttons and such in the second controller's view. The code behind those would then go into the second controller.
If your purpose is simply to have superviews to control layout within a single view controller, use a UIView rather than a container and the problem goes away. That's what the Editor->Embed In->View menu item is for.
I have some menus in my app wich are all presented modally. In my tests I noticed that the more often I switch between menus the more UITransitionViews are show in the View Debugging Window in Xcode when i capture the View Hierarchy. Is this a normal behavior are am I missing something here. Do I need to dismiss ViewControllers somehow?
I attached a screenshot for better understanding.
You do, I had the same issue and the app memory usage was going up the more I switched between views (views were not dismissed).
You should use delegate where the child view controller can call so the parent view controller can dimiss children properly.
I have a basic Cocoa app to try out Swift and Storyboards.
The app consists of 3 main views that are managed by an NSTabViewController, which again is linked to the main window's "window content" relationship.
I added an NSSegmentedControl to the window's toolbar to switch between the 3 tab views.
In the main window controller I added the action method for the toolbar item to switch between the tabs, but I can't figure out how to get a reference to the tab view controller to actually switch tabs.
I tried adding my action method to the tab view controller, but that does not work, because the tab view controller might not be in the responder chain if it contains an empty view (is this a bug?).
As a workaround, I overrode viewDidAppear() in the tab view controller. There I get a handle to the view.window.windowController and set a reference to "self" in an instance variable. This works, but does not seem right. There should be a way to get from the window controller to it's content view controller...
The window controller and tab view controllers live in different scenes, to I can't connect them through IBOutlet. Also, none of the segue methods are called on the window controller either for the "window content" relationship.
I know I'm incredibly late, and maybe it didn't exist when that question was posted, but for anyone landing here, the NSWindowController has a contentViewController: NSViewController? property (added in macOS 10.10, so around the end of 2014 I think).
I'm mainly an OS X guy, and I'm new to StoryBoards myself, but I think what you need to do is:
Write your
-(IBAction)someResponse:(id)sender {}
method in the view controller that plans to handle the action.
Wire the Control so that it sends its action to its FirstResponder. If your view controller is in the responder chain, it'll receive it.
I made a log-in screen that once you press the button to log-in and it authenticates the user name and password. What I want to do it switch to a different view after the authentication is completed. I am using a storyboard for this application and I have set it up so that the log-in button does a modal seque but it doesn't switch the view. I tested this with a sample button and all it does it switch the view back to the same view and refreshes the view. What do I need to add in order for my function to switch from my ViewController View (the main view) to the next view (RootViewController).
I have a navigationController and an object created from the ViewController class but I don't know how to use them in order to switch views.
Can anyone point me in the right direction? I can provide more information or sample code if needed.
If I'm following your question correctly, what you're looking for is performSegueWithIdentifier:sender:.
In general the apple documentation on view controllers in storyboards is pretty good and covers all of the relavent bits for transitioning between views in storyboards.