Segue from a SLPagingViewSwift VC and dismiss the destination VC to return
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 IOS swift return to the main page from multi-segue relationship page
Look up unwind segues!
What you should do is to create an unwind segue instead of a normal push segue from the 4th VC to the first VC. You basically have to write this method in your first VC:
@IBAction func unwindFrom4thVC(_ segue: UIStoryboardSegue) {
}
Then connect the 4th VC with the "Exit" of the first VC, then select the above method in the pop up that appears.
The unwind segue won't show up in the storyboard but you can find in the document outline. Select it, give it an identifier, and perform it using:
performSegue(withIdentifier: "your identifier", sender: yourData)
where yourData
is the data that you want to remember.
Now in prepare(for:sender:)
, you can do this:
if let vc = segue.destination as? YourFirstVC {
vc.data = sender as? YourDataType
}
data
is a property you need to declare to receive the data from the 4th VC, and YourDataType
is the type of that data.
View unusable after dismissViewControllerAnimated:completion:
I was setting translatesAutoresizingMaskIntoConstraints = NO;
on my root UIView
.
It appears the "outermost" UIView
— the superview at the root of your view hierarchy must use the default translatesAutoresizingMaskIntoConstraints = YES
.
Once I've removed this, everything worked as expected.
Proper way to end an Async process
GDC is not easily cancellable.
Use an NSOperation
subclass then you can cancel easily and quickly.
Tinder-like navigation in swift
Okay. I have downloaded your project, because your explanation wasn't really helpful..
First of all: If you have a storyboard with nothing but blank screens, color them for other coders to be able to tell faster what's going on.
Your segue from the yellow VC
to the UINavigationController
is triggered, but not used because you instantiate the UINavigationController
programatically.
// Sets the root
func setNav() {
// here
nav = MainNavigationController(rootViewController: controller)
appDelegate.window?.rootViewController = nav
appDelegate.window?.makeKeyAndVisible()
}
Your segue from the green VC to the blue VC doesn't make any sense because there is no segue. Those controllers are embedded into the same controller.
You are setting up the perform(forSegue
function, but you are never calling it. You only use perform(forSegue
if there is a segue. But that is not the case.
Setting the button without the setNav()
function:
@IBAction func buttonSegue(_ sender: Any) {
//setNav()
self.performSegue(withIdentifier: "segue", sender: nil)
}
Results in the blue VC
as single VC
.
Same function without the segue, results in the same logic, as with the segue. Because as said, you set up everything programatically anyways:
@IBAction func buttonSegue(_ sender: Any) {
setNav()
//self.performSegue(withIdentifier: "segue", sender: nil)
}
Since you have instantiated the VCs
globally, you are able to get/set VCs
values globally...
class OneVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func passData(_ sender: Any) {
let oneVCString = "This String is passed from OneVC"
twoVC?.theLabel.text = oneVCString
}
}
And the outcome:
Here is this on Github as a fork of your project. Also I have deleted your code from the AppDelegate
. Wasn't useful and called anyways. You did the same in the Interface Builder already.
Last but not least a comment from me: Clean up your code! Other users might have a different opinion on that, but this is not how I want to work with other coders:
import UIKit
class TwoVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
print("from two to...")
print(segue.identifier!)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Remove all the unnecessary comments.
Auto layout invalid after presenting view controller (and many situation)
I had a similar problem. I was setting translatesAutoresizingMaskIntoConstraints = NO;
on my root UIView.
It appears the "outermost" UIView - the superview at the root of your hierarchy must use the default translatesAutoresizingMaskIntoConstraints = YES
.
Once I've removed this, everything worked as expected.
Find two consecutive rows
Assuming the rows have sequential IDs, something like this may be what you're looking for:
select top 1 *
from
Bills b1
inner join Bills b2 on b1.id = b2.id - 1
where
b1.IsEstimate = 1 and b2.IsEstimate = 1
order by
b1.BillDate desc
Related Topics
How to Implement Copy Constructor in Swift Subclass
Swiftui Call Function on Variable Change
How to Create a String from Utf8 in Swift
How to Test Whether Generic Variable Is of Type Anyobject
Why I Can Change/Reassigned a Constant Value That Instantiated from a Class
Swift Error: Missing Return in a Function Expected to Return 'String'
How to Create Several Cached Uicolor
Read Data Firebase Assign Value
Lazy Loading Properties in Swift
How to Improve Camera Quality in Arkit
Writing Data to an Nsoutputstream in Swift 3
Rxswift Map and Flatmap Difference
Differencebetween Swift 2.0 Do-Try-Catch and Regular Java/C#/C++ Exceptions
Swift Error: Binary Operator '&&' Cannot Be Applied to Two 'Bool' Operands
Swift: Second Occurrence with Indexof
Beginner Swift Sprite Kit - Node Collision Detection Help (Skphysicscontact)