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.
Related
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 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.
I have a problem with accessory views on NSSavePanel and NSOpenPanel.
Sometimes, (very often) when I open one of these panels the accessory view does not work (the view is shown but controls seem disabled).
I'm using this code to show the panel:
[openPanel beginSheetModalForWindow:appWindow completionHandler:openPanelHandler];
This only happens when app-sandbox is enabled.
After much testing I found out that what was happening was that the view was being misplaced (not attached to the panel).
When I open Mission Control and move the mouse pointer over the app windows I noticed that an "invisible" window hilighted and when select it I can take control over the accessory view (all controls work) but it appears detached from the open or save panel as shown on the screenshot.
I tried to create a new app just to test this behavior but was not able to reproduce it, so I suppose that has something to do with my app.
Any hint of what I may be doing wrong?
I don't want to code everything from scratch just to solve this issue.
Edit
Just a side note, when I close the window, just before the window close the accessory view flashes with the correct values for the controls. It appears that the application does not add the view in time for showing the panel.
Update 1
I subclassed the view that is used as accessory view and noticed that the
- (void)viewWillMoveToSuperview:(NSView *)newSuperview
is called, but
- (void)viewDidMoveToSuperview
never gets called even when the view is shown correctly, is this the normal behavior?
Update 2
I confirmed that - (void)viewDidMoveToSuperview should be called, on the test app both methods are called.
I also noticed a slight difference between my app and the test app. On my app the panel just slides down but on the test app the panel appears to "flip down" (don't know exactly how describe). The way the panel appears is irrelevant to me, I just noticed that it is not shown the same way.
After trying many things I concluded that the problem had to do with ARC (Automatic Reference Count) settings for the project.
In my case I had enabled ARC on target but not on project, after enabling ARC on project (and dealing with resulting errors and warnings) everything works perfectly now.
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.