View in Viewcontroller disappears - swift

Having a bug when i try to delete viewcontroller2 which is connected to vc1. Part of the view in viewcontroller1 seems to disappear even though i remove all connections. Ran in to this problem before on same project when connections were not right.
The first image is how it is supposed to be with listname and a button in lower corner.
The last image is how the tableview looks like when i try to remove the other vc.
Any idea of how to solve this?

I don't know if this is what you want but try putting this in the function for when vc2 closes:
self.navigationController?.popViewController(animated: false)
dismiss(animated: false, completion: nil)
self.view.removeFromSuperview()
self.view = nil
If you provide some code it will be easier to understand.

Related

Close a Page Sheet VC through pulling in down

I'm trying to close a VC on a special way.
As the title says I want it to be covered vertical but not from down to top, but the other way.
i tried all things I found but non of them helped. I´m using Navigation controllers and if I pull the VC with my finger down it works, but if I use my back Btn it covers from bottom to top.
Currently the button code is pretty simple:
self.performSegue(withIdentifier: "BackToFriends", sender: nil)
Where do I have to define In which way it closes?
Thanks for every help
Ups it´s really simple.
Just using self.dismiss(animated: true) and that´s it

When tabbar is hidden it leaves a black space

When I call tabbar.isHidden = true in viewWillAppear it leaves a black space. No matter what I try, nothing is helping. I have tride `hidesBottomBarWhenPushed, tried to change the tabbar size to 0 and so on. In another project of mine it works, but not in this one.
Anyone have a solution?
Oh, I am not using Storyboard, I do everything programmatically.
5 minutes later, here we are again ...
I have found the solution!
I called tabBar.isTranslucent = false in my MainTabController. When calling tabBar.isHidden = true in my other views, it did only hide the tabBar but did not make the translucent part go away.
So yea, I hope you understand the solution, if you should ever run into a similar problem, make sure to check if you call isTranslucent anywhere
Suppose you are redirecting from view controller A to B, when you are creating instance of view controller B (Inside view controller A) to redirect. Try like this it worked for me.
let vc = IKSikSearchViewController()
vc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(vc, animated: true)

Swift View Controller won't dismiss

so I have a basic game going in Xcode. I started with Xcode's basic game template and built my game mostly inside the 'GameScene.swift'. When I finished with my game I wanted to add a start screen with a play button so I made a new UIViewController and added a button. I control click and dragged the button to the GameViewController and created a Modal Segue. I then wanted the game to go back when the player died. I tried various ways to dismiss the view but none worked. I am new to swift and really need help. Let me know what code/info is needed to find a solution. I have tried everything I have found on the internet. I thought I found a way around it by adding a button and Segue to the GameViewController to the menu but after multiple pushed it clogged the system and slowed to a crawl because none were dismissed. I can provide any code needed.
Inside of GameViewController.swift in the GameViewController class I tried making a function that was called when the game ended.
I tried to both pop and dismiss the view controller. The function was called and a line printed to console but the view remained. The only thing printed to console is 'nil'
class GameViewController: UIViewController {
func end(){
print(navigationController?.viewControllers as Any)
self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: nil)
}
# Vollan heres the pic
Here is the screenshot of the storyboard.
thanks in advance.
If you pushed the viewController you use self.navigationController?.popViewController(animated: true)
If you presented it modally you use
self.dismiss(self, animated: true)
When its presented from a modal segue you use
self.presentingViewController?.dismiss(animated: true, completion: nil)
I have a modal segue in a storyboard from one view controller to the other. Then I have a button that's connected to an IBAction that just runs
dismiss(animated: true, completion: nil)
Check and redo the connections from the storyboard to the code. Xcode sometimes just looses a connection when making a lot of changes to the code.

Segue from a SLPagingViewSwift VC and dismiss the destination VC to return

***** You can download this project to see the issue *****
I've embedded SLPagingViewSwift in my project.
In the third VC i added a button (and a table):
The button configured to do a segue (Present Modally):
In the target VC i have a button (marked in square green above) that do:
#IBAction func dissmissIt(_ sender: AnyObject) {
dismiss(animated: true, completion: nil)
}
But after the target VC is dismissed i see the button in the third VC in a different location (higher):
The layout is configured, button 40 pixels from the top (and table 8 pixels from the button):
What went wrong?
I guess the initial layout configuration takes the SLPagingViewSwift navigation bar into consideration but after the dismiss it recalculates the layout from the top of the screen.
What is the right way to perform the segue and dismiss the target VC while keeping the layout as designed?
I saw this answer
But i was not sure where to use it. i tried:
nav?.view.translatesAutoresizingMaskIntoConstraints = false
and
controller.view.translatesAutoresizingMaskIntoConstraints = false
But with no luck.
***** You can download this project to see the issue *****
Thanks.
I had the same problem. After a lot of hour trying to fix it, I found the solution.
Click on your segue
On the right panel click on 'Show the attributes inspector'
Set the Presentation option to 'Over Full Screen'.
Worked for me. I hope it works for you!

How to return from "partial curl" type segue

I am attempting to use a partial curl segue to reveal an options view underneath my main view. This is identical to touching the "page curl" button in the bottom right corner of the Maps app.
I can successfully execute the segue to the option view, my problem is returning to the main view. I'm hoping to replicate the reverse animation effect of the Maps app as the edge curls back flat and the main view is shown.
It doesn't seem logical to create another segue to return back to the main view (what I would do if I were not using the partial curl segue) because the return segue is associated with the original segue.
Thanks in advance for any help!
try
-(IBAction) buttonPressed{
[self dismissModalViewControllerAnimated:YES];
}
This should work!
Or i believe you can press the back side of the turned page and it will return automatically with out adding any code! Hope that helps!
In Swift dismissModalViewControllerAnimated has been renamed:
#IBAction func handleAddButton(_ sender: Any) {
self.dismiss(animated:true, completion: {})
}