I have a view controller (lets call it AViewController) which has a background image, buttons, etc. I also have a second view controller (lets call it BViewController) with its own set of buttons. When i transition from one view controller to another, the background image along with the UI Elements of the first view controller is being displayed in the second view controller. I am using a segue. I faced with problem before. What i did to correct it was change the background colour of the view from white to clear color. But it doesn't not seem to work in this case. (The BViewController contains a UIView in which the user can draw.)
Related
When my app performs a certain segue, I want the new view to be shown on top of the previous view, like a background. How do I do this?
If this is not possible, is there any way I could programmatically take a screenshot of the previous screen to use as a background for the new screen?
There's a method on UIView, snapshotViewAfterScreenUpdates: than will give you a composite view of the current screen. You could use that for your background.
You might look into custom view transitions to do what you're after though.
Instead of a segue to a different view controller, why not just add the new view to the current controller, place it so that it appears above the first view and then set it as hidden.
When the user taps the action that would trigger the segue (a tableview cell for instance), then instead to triggering the segue, just mark the second view as visible and populate it's content with what you need to display.
With a clear background on the second view, it will overlay the original view. Then you can just add some control to hide it once they're through.
I have a viewController which displays a map with annotations. When I click on a bar button, another viewController is supposed to animate on top of that. This works, BUT, when the animation completes, the viewController in the back disappears. It reappears again when the animated viewController closes again.
Here is a video of what happens - hopefully that will make things more clear:
Let me know if I should include the code as well.
When you present a view controller it is expected to take the full screen. As such, the view controllers 'below' it have their views removed from the stack to save resources which are expected to not be required.
You can change your presented view controller to do something like:
Either, don't be presented, just add a subview and animate it in.
Or, pass an image of the original view to the presented view, this becomes the background and that presented view animates a subview in over the image background.
I know it's possible to set a background image for the UINavigationBar, but I would like to know if there is a way to share a common background view for all controllers in a UINavigationController. The idea is to have a UIImageView as the background that stays in place rather than "sliding" over itself when navigating to a new controller.
A navigation controller is a kind of view controller and it hosts the currently visible view controller by adding the VC view to its view. You can add things to that view too. Create your image view and add it as a subview of the nav controller view, then send it to the back (or insert at index 0).
I have the task to design a application that has a main view which is always visible (it has a button on it's bottom side, and when pressed a image displays on top of all views), and a set of TableControllerView's that should appear under it, and the user needs to be able to navigate through them.
I know that you can embed a view inside another, but you cannot refer more than one view to it. The current way I'm trying to do now load one TableViewController inside the embed view, and when the user clicks the cell I manually load the other controller and add it as a child of the main view, which is the RootViewController. The problem with this approach is that the navigation bar gets stuck using the root view controller, so I have to manipulate the main navigation items on each subview transition, and second is that the frame for the second view I load is coming as it had full size, making some cells be under the main view button. This way doesn't uses segues for transition, so it makes the storyboard kinda useless.
I was thinking into using a TabViewController with it's tab hidden, but wanted to ask here for a better solution.
As you discovered, a TableViewController likes to fill up the whole screen (except navigation bars, tab bars, status bar, etc. which are official Cocoa Touch GUIs). When you want a table view to fill only part of the screen, you are supposed to use a UITableView but not a UITableViewController. You set your custom view controller object (subclass of UIViewController, not UITableViewController) as the table view delegate and data source. You will need to duplicate part of the functionality of UITableViewController in your custom view controller, but it's not a lot more than you have to do already to supply the data.
You should probably follow the standard design pattern and have separate view controller objects for each of the "pages" the user can navigate to. You just have a main button and image on each of them. But I could imagine why that might not give you exactly the effect you want.
I have a popover that gives a list of options to the user, and when the user clicks it pushes another view onto the stack. This works fine for the first view, but once one of the larger views is opened, the popover window won't shrink down to size when the user backs out of the navigation workflow. I've tried calling sizeToFit on the child views and on the navigation view, but it doesn't seem to have an effect.
How can I make sure the popover and navigation controller are the correct size for the current view being shown?
Normally in this type of workflow, let's say you start with VC1. From VC1, you present a popover to user with selection choices. User makes a selection from the list (a tableview, etc.) You then need to (from the popover) make a callback to VC1 and pass back along any data which in this case user's selection to VC1. VC1 then dismisses the popover and then prepares another view controller with that data and push the new view controller on to the display/navigation stack. That is a pattern I would use.