segue

Prepare For Segue With Array - Xcode 8.0 Swift 3.0

余生长醉 提交于 2019-12-02 16:48:17
问题 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

ContainerView with multiple embed segues

你离开我真会死。 提交于 2019-12-02 15:28:35
Is there a way to have a single ContainerView with multiple embed segues? The aim is for a ContainerView to hold a few different ViewControllers depending on what buttons have been pressed; only one is going to be visible at a time. I want to use embed segues so that in Interface Builder the storyboards are automatically shown at the same size as the ContainerView. I realise that I can manually resize the other ViewControllers in InterfaceBuilder, but I want the automatic sizing provided by the embed segue. If another way of doing that is available, that would be fine too. Not having the views

Passing Data Through Segue (swift 2)

我的梦境 提交于 2019-12-02 14:23:01
This is a Tip Calculator Project and It must have a settings view where I select the default tip rate. I have some issues with passing data, when I select a default tip percentage it doesn't change in the View Controller, also I want to make the app remember the default rate when I close the app and reopened. I will really appreciate that some one corrects my code and test it. This is for entering a Computer Science Program in college, I don't have previous experience with any programming language before. 100 TipPercentageLabel.text = "(tipDisplay)%" } } override func didReceiveMemoryWarning()

Attempting to segue from Objective-C to Swift VC

放肆的年华 提交于 2019-12-02 14:10:14
问题 i'm trying to segue from objective-c to swift. However when I try this using the object below I receive the following error I don't know what i'm doing wrong, i've setup the segue on the storyboard and assigned it to the same ID, created the prepare function and the perform. - (void)renderer:(id<SCNSceneRenderer>)renderer willRenderScene:(SCNScene *)scene atTime:(NSTimeInterval)time { // Look for trackables, and draw on each found one. size_t trackableCount = trackableIds.size(); for (size_t

How to stop UITableView from returning to top cell after popover

风流意气都作罢 提交于 2019-12-02 13:23:18
问题 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

How to pass data in conditional unwind segue?

假装没事ソ 提交于 2019-12-02 13:00:37
I try to build an rss reader. On the "adding feed" page, if I tap the "add" button, I hope to check if the feed is successfully added. If it is added, then trigger the unwind segue, and back to the main page. If it is not added, stay in the current page. I know I can build an IBAction on the "add" button, and check if the feed is added. However there are two requirements I need to meet in order to add a feed. First, after I parse the url, I need to know if the parse results can generate a feed. To parse the url, I need to use the method defined in the mainViewController. Second, I need to

Create a segue and attach it between two view controllers through Swift?

随声附和 提交于 2019-12-02 12:58:04
问题 How would we create a segue in swift programatically, without using Storyboards. I cannot use storyboards because of how the app is structured, so I need to know how to do it programatically. Essentially, all I want to do is create a segue, and attach it between the source and the destination. So far, I have created a RollSegue class which is a subclass of UIStoryboardSegue. Now, I'm trying to do the following: var seg: RollSegue = UIStoryboardSegue("roll", self, destination) and I have also

Xcode - Segue issues

南笙酒味 提交于 2019-12-02 11:28:08
i've been trying to get a segue to work. I've written the following... but for some reason, the ...preparesegue... method doesnt fire. I've read other related posts but i cant get it to fire, and just as importantly, the variable i'm need isnt transferred. m file: @implementation CountryTableViewController -(void) getData:(NSData *) data { NSError *error; json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; [self.tableView reloadData]; } -(void) start { NSURL *url = [NSURL URLWithString: URL]; NSData *data = [NSData dataWithContentsOfURL:url]; [self getData

How to perform conditional segue

时光怂恿深爱的人放手 提交于 2019-12-02 11:27:23
I've created a segue through IB. When buttonA is clicked, a transition to viewB will occur. In the button click action, I have performSegue(withIdentifier:sender:) wrapped in a condition. I want the segue to occur only if the condition is true. However, once the user clicks the button, the segue happens before the condition is even run. What is the best way to transition programmatically while still using segue identifiers defined in IB? You have created segue from the UIButton to a viewController that is the reason segue happens before the execution of condition. Instead of that remove that

Page views not correctly sized after segue

限于喜欢 提交于 2019-12-02 11:13:16
I recently updated my XCode to version 11.0. Ever since the update segues on an old project have been behaving weirdly. When I segue modally to a new page the page does not fill the entire screen and seemingly hovers instead. Here is a picture of the view: https://imgur.com/dAxEr4q I would like for the pages to take up the full length of the device screen as they did prior to the upgrade. Thanks in advance for any assistance. This has to do with the new default modal presentation style in iOS 13. To set the prior behavior, you need to change the presentation style to full screen. You can do