I want to dismiss current view controller and show new view controller.
For example, a chatting application needs view controller for making chat room.
Let main view controller is A and view controller making chat room is B and chatting room is C.
When make new chat room, I have to go B and create then automatically present C. But when I dismiss C, I want to go A not B.
You may say "Oh, unwind can solve your problem!", but that's not I want.
I want to delete useless middle viewcontroller B.
And I saw article below
How to dismiss the current ViewController and go to another View in Swift
But for me, it doesn't work. It just dismiss or just present new view controller or present view controller and dismiss it as soon as show it.
Please help me!
If I correct understand, you can save A controller reference for example in AppDelegate:
var ANavigationController: UINavigationController?
and then create custom segue, where destination controller will be ANavigationController
You can use button to comback from C to A.
Or you dissmiss C and in deletage of C in B, you detect when C dissmissed, you also dissmiss B.
Related
While writing an app in Xcode8 (swift3) for adding pictures with titles I set up two view controllers, the first of which was embedded in navigation controller. I’ve added an “Add” barbutton in the navigation control of the first view controller (VC), tapping which, the second view controller is shown. I receive the following error when I tap on the “Add” button on the 1st VC.
"objc[692]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x155d38cc0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x154b876f0). One of the two will be used. Which one is undefined."
Can somebody please help me understand the issue and to solve it.
I have an app that has two navigation controllers. I'm trying to create the segue shown in the red arrow below: Pressing the "+" button should take you to a specific view controller of another NavigationController.
I've been able to successfully go to this view controller but it doesn't have any navigation properties (Pressing "Back" doesn't do anything).
How do I jump to a view controller in a different navigation controller but still retain navigation properties?
I will say you want to move from controller A to controller B for reference.
Each UINavigationController instance has a viewControllers array that stores the controllers in the navigation stack.
In your case, the first navigation controller has 2 view controllers in the navigation stack, the same thing for the second navigation controller.
If you press back in the view controller B, it should pop to one of the view controllers in the UINavigationController stack to which B belongs. Since controller A et B don't belong to the same UINavigationController, hence you cannot access the pop API to move back.
One way is to present controller B modally from controller A instead of pushing it.
My root view controller is an UISplitViewController, which has a UITableViewController as master view controller. On iPhone (compact width), it looks like a UINavigationController.
Tap a cell to show detail view controller
Tapping the trash button would delete the current note. My problem is how to go back to the master view after that? Since it's an UISplitViewController, it can't pop the current view controller as UINavigationController does.
I had a similar problem and finally found a solution. As I understand it, when in compact width, the detail navigation controller becomes a view controller of the master navigation controller. So all you have to do is:
Determine if only one view is present by checking the split view controller's collapsed property. If it isn't collapsed (e.g. on iPad), you're already showing the table view in addition to the detail view.
If it is collapsed (e.g. on iPhone) get a reference to the master navigation controller via the detail navigation controller and have it pop to its root view controller which, in this case the your table view controller.
This is the code I use in my detail view controller. In your case I think you just need to add this code to the button action in your detail view controller:
if splitViewController!.collapsed {
let detailNavController = parentViewController as UINavigationController!
let masterNavController = detailNavController.parentViewController as UINavigationController!
masterNavController.popToRootViewControllerAnimated(true)
}
Good luck!
I have a main view controller. When a specific button is pressed, I present another view controller. When the second view controller is dismissed, I want to call a function in the main view controller. Originally I thought I could just use the completion handler for presentviewcontroller, but now I'm thinking that is not the way to go. Any tips on how I can accomplish this? I'm pretty new to this, so any help would be appreciated!
Assuming your main view controller is the second view controller's parent, you can access the method with:
[[secondViewController parentViewController] method];
Beware -- if you are using a navigation controller, the parent view controller will be the navigation controller. In this case, you will have to query the navigation controller's stack.
Good luck!
I am using storyboard seques to change views to other parts of my app but when I linked my main view to the next and called for the seque in the function within my enter button it just loops back to my main view and refreshes the app.
Here is my function call:
[self performSegueWithIdentifier:#"Enter" sender:self];
In the storyboard I have my main view linked to the next view with the identifier "Enter" but I still get send back to the same view. Is there any way to specify the destination of the next view? Do I need a certain variable from the other view controllers the need to be imported to the code of the main view controller?
I can provide more code or information if needed.
Picture: http://i1180.photobucket.com/albums/x411/Ryute88/screen.jpg
Identity Inspector Picture: http://i1180.photobucket.com/albums/x411/Ryute88/screen2.jpg
Picture 3: http://i1180.photobucket.com/albums/x411/Ryute88/screen3.jpg
Thanks in advance.
Please check this site: All about storyboarding
You will find details on doing your stuff.Try that and check if the problem still exists!
Are you using the write segue to call on the next view e.g. pop can only be used in case of Navigation Controllers.
In any case the problem will be trivial because storyboards do everything for you.