segue

prepareForSegue not called when UITableView row selected?

こ雲淡風輕ζ 提交于 2019-12-12 07:25:33
问题 I have setup a UITableView using a NSFetchedResultsController that displays a number of prototype UITableViewCells. I have hooked up a push segue from my UITableViewCell to my DetailViewController. In my TableViewController I have implemented both: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"%s", __PRETTY_FUNCTION__); [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:

Swift: How to use “didSelectItemAtIndexPath” in UITableViewController(contains UICollectionView)?

北战南征 提交于 2019-12-12 07:22:27
问题 I have a UITableViewController , inside the TableViewCell , it's a UICollectionView . I want to pass the data from the CollectionViewCell to a DetailViewController when user tapped the cell. I dragged a segue from the CollectionViewCell to the DetailViewController , and used the didSelectItemAtIndexPath inside the TableViewCell ( which contains CollectionView ), and it works. class TableViewCell: UITableViewCell, UICollectionViewDataSource, UICollectionViewDelegate { var posts1: [Posts] =

Segue won't execute Swift

自作多情 提交于 2019-12-12 06:21:29
问题 I have a segue running form a Collection View (wrapped in a view controller) in to a another view controller, how ever the function never gets called: func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { println(segue.identifier) println(sender) println("SEGUE SELECTED: \(segue.identifier)") if(segue.identifier == "segueToDetailView") { let cell = sender as CollectionViewCell; } } Have placed a breakpoint at start of function but never reached. Any input appreciated. 回答1: I

Segue to different controllers from one view controller

可紊 提交于 2019-12-12 05:53:14
问题 I have a table view with a few different prototype cells. I want to have one prototype cell segued to one controller and the rest should not be clickable i.e. no seg. Right now, I have one button linked to a controller successfully but when I tap on the tableview prototype cell which is segued to a different controller (in the storyboard) nothing happens. I don't get any error either. What is the best way to go around this? Can I make two different segues in the storyboard? Or do I need to

Change Viewcontroller based on device orientation in iOS 8/9

拜拜、爱过 提交于 2019-12-12 05:32:24
问题 What is the preferred way of segueying between two viewcontrollers based on device orientation in iOS 8/9? I want to build an instrument that is shown in landscape. In portrait i want to show the settings of the App. 回答1: In AppDelegate.swift inside the "didFinishLaunchingWithOptions" function I put: NSNotificationCenter.defaultCenter().addObserver(self, selector: "rotated", name: UIDeviceOrientationDidChangeNotification, object: nil) And then inside the AppDelegate class, put the following

Swift sending Multiple Objects to View Controller

99封情书 提交于 2019-12-12 05:28:39
问题 I am trying to send multiple objects from my initial view controller to my Username VC . Here is the segue code from my controllers: The issue comes when I add in the code to send the second object, termreport . If I delete the termsM and the assignment, it send the students as usually, but I also need to send the termReport object. How would I fix this? ViewControler : override func prepare(for segue: UIStoryboardSegue, sender: Any?) { guard let students = sender as AnyObject as? [Student]

Cant pass value to another viewController?

五迷三道 提交于 2019-12-12 05:09:15
问题 I have some text in tableview cells which you will tap on it you will pass the name of the cell and also you will be pushed to another view. override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath as IndexPath, animated: true) let row = indexPath.row valueToPass = sections[row] print(valueToPass) } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if (segue.identifier == "fromWelcomeToSectionPage") { //

Create different segues from one tableView

喜欢而已 提交于 2019-12-12 05:04:16
问题 I created a menu inside of my app. The menu has 4 cells, which are created by modifying a prototype cell. Each of those cells should perform a segue to one of 4 ViewController s. How can I realize this? Any ideas? 回答1: You can either: 1) Create 4 prototype cells having each one wired directly to its respective viewController. In this case, each give each prototype cell its own identifier (for example "cell1" , "cell2" , "cell3" and "cell4" ) and then in cellForRowAtIndexPath dequeue using the

Manual unwind segue from UIImagePickerController fails with 'Receiver has no segue with identifier'

自闭症网瘾萝莉.ら 提交于 2019-12-12 04:48:14
问题 I've almost finished converting a large Universal app to use Storyboards, but have one issue that is stumping me. I have created a Scene for a custom UIImagePickerController, but I can't figure out how to unwind from it. I know I could just dismiss the controller, but I want to use the unwind process to pass the image back to the original source view controller. When I try to do the manual unwind, I get the following exception: 'NSInvalidArgumentException', reason: 'Receiver (

perform segue and send tuple as sender

风格不统一 提交于 2019-12-12 04:29:01
问题 I've been trying to set a tuple to the sender object when doing a perform segue like: performSegue(withIdentifier: "", sender: ("hello", "hello2")) But inside override func prepare(for segue: UIStoryboardSegue, sender: Any?) I'm getting cast exception when trying to cast sender as (String, String) It seems that only the first element of the tuple is in sender . I'd expect since sender is of type Any? I could use a tuple as variable? Has anyone else experienced this? 回答1: Per the documentation