segue

Prepare For Segue With Array - Xcode 8.0 Swift 3.0

一笑奈何 提交于 2019-12-02 10:38:55
What is the best way to add an item to an array on one VC and then use "prepare for segue" to transfer the array to another VC? So far this is what I have managed to come up with: (VC1) var items: [String] = ["Hello"] (VC2): override func prepare(for segue: UIStoryboardSegue, sender: Any?) { var destViewController: ViewController = segue.destination as! ViewController destViewController.items = [textField.text!] items.append(textField.text!) } On VC2 an error is coming up that states, "use of unresolved identifier" on the line items.append(textField.text!) I am pretty new to iOS/Swift but I

Errors while using shouldPerformSegue(withIdentifier, sender) method in swift4

怎甘沉沦 提交于 2019-12-02 10:17:40
What I'm trying to do: checking a condition, if the condition is true, perform segue as normal. If condition is false, call the shouldPerformSegue method and return false to cancel the segue. How I'm trying to do this: func buttonTapped{ if(condition is true){ // Perform actions // Perform segue as normal } else{ shouldPerformSegue(withIdentifier "mySegueIdentifier", sender: self){ return false } } } Errors I am receiving: extra argument in call. I removed the sender parameter to try and get this to work, and it got rid of the errors for me, but the segue still performed when it shouldn't. I

Passing array through segue in swift

自闭症网瘾萝莉.ら 提交于 2019-12-02 10:01:49
I've been struggling for a few days now with passing an array from my SecondViewController to my FirstViewController using Swift. From my research I found that segue with prepareForSegue would be a viable option but I can't seem to figure it out. What am I doing wrong? My prepareForSegue in SecondViewController looks like this: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { var DVC: FirstViewController = segue.destinationViewController as! FirstViewController DVC.mySeguedArray = myIncomeArray } My FirstViewController looks like this: class FirstViewController:

IOS/Objective-C: Possible to Use Custom Segue in Modal Transition in Absence of a Storyboard Segue?

为君一笑 提交于 2019-12-02 09:59:52
I have two View Controllers in Storyboard and I would like to present the second one from the first modally using a custom downward segue (the opposite of the regular cover vertical). I have subclassed storyboard segue with code that I hope will work. However, in this instance, I did not drag a segue in Storyboard from one view controller to the other. Instead, I handle the Modal Presentation in code. Is it possible to invoke a custom segue if you are calling the second view controller in code? Or do you have to have an actual segue in storyboard to which you assign the custom class? If

Pass data Through segue not working in swift 3 any solution?

独自空忆成欢 提交于 2019-12-02 08:38:44
i have passed data from didselect method of collectionView like this func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let dicttemp = (arrRespProduct?.object(at: indexPath.row))! as! NSDictionary dicData = NSMutableDictionary(dictionary: dicttemp) performSegue(withIdentifier: GlobalConstant.segueIdentofier.productDetail, sender: self) } But method func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) is not calling in swift 3... Any solution? prepareForSegue is changed in swift 3.0 so you need to write like this override func prepare

How to make Segue Pass Data AND ONLY execute if certain criteria is met

别等时光非礼了梦想. 提交于 2019-12-02 07:49:09
问题 I have a Login page with a button. When I click on it, IF and ONLY IF the login was successful, I want to pass data to another class (using properties). I have tried using a Segue on the Button to pass the data, but the problem is that this Segue always goes to the next View, EVEN when the login is unsuccessful, in which case it should NOT. -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"gotoMainPage"] ) { MainPageController

Slowing Down Transition of Push Segue

孤街醉人 提交于 2019-12-02 07:37:43
I was wondering if there is a way to slow down 'push segue & back' like Tinder & Snapchat does. It's like normal segue but it's somehow transiting slowly. I normally handle push segues with setting up a Push notification on Storyboard and programatically calling the segue (clicked on NavBarItem and push segued to new UIViewController) : func settingsTapped() { performSegueWithIdentifier("NewsToSettings", sender: nil) } It there a way to enable slowing down segue globally for the whole app? or should I do it maually for each segue? If so, what is the appropriate way? I was wondering if there is

My Tab bar controller disappears after a push segue

左心房为你撑大大i 提交于 2019-12-02 07:25:58
Here is the setup of my app: Navigation- -loginVC -if login is valid, pushes segue to- tab bar controller with 3 tabs: -in the first tab, is a profile display which modal pushes to a profile editor(not issue here) -second tab is a searchVC that pushes to a tableVC that shows results. This is where the tab bar disappears -The third view is just a VC for updating the database this is linked to. This is literally how it works on the storyboard, and I've made sure the segue from the searchVC to the tableVC, is a push segue. How can I keep the tab bar controller from disappearing on this second

How to stop UITableView from returning to top cell after popover

南笙酒味 提交于 2019-12-02 07:12:06
I have a tableView full of images. When a user taps on an image (within the cell), a viewController with a larger zoomable version of the image is called with a popover segue. When i dismiss the popover and return to my tableView, it automatically displays the top cell of the table. Is there any way to stop this happening, and return to the previous position/cell before the popover was called? EDIT: To call the popover i use performSegueWithIdentifier("segueToPopOver", sender: tap.view) to dismiss it i use the following: let tmpController :UIViewController! = self.presentingViewController;

How to make Segue Pass Data AND ONLY execute if certain criteria is met

余生颓废 提交于 2019-12-02 06:18:12
I have a Login page with a button. When I click on it, IF and ONLY IF the login was successful, I want to pass data to another class (using properties). I have tried using a Segue on the Button to pass the data, but the problem is that this Segue always goes to the next View, EVEN when the login is unsuccessful, in which case it should NOT. -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"gotoMainPage"] ) { MainPageController *mpc = [segue destinationViewController]; mpc.username = @"TEST"; } How can I make the Segue ONLY go to