Unwind Segue with UITableViewCell in Xamarin.iOS - ios

Can someone tell me definitively if there is a limitation with using Unwind Segues with UITableViewCell or if not how to achieve this?
I can successfully implement an unwind segue from my second view controller to my first - triggered using a simple UIButton.
However, when I try to use a UITableViewCell to create the unwind segue (drag from the TableViewCell to the green Exit icon then I do not get an option for Action Segue. Instead I get options for "Selection Segue" and "Accessory Action".
How can I trigger the unwind segue on selection of a UITableViewCell?

Selection segue will fire when you select the cell. Accessory action will fire when you tap the cell accessory. unwind: underneath the Selection Segue is the one you want to choose here:

Ok. I'm a little embarrassed at my error here. I hadn't created an outlet for my UITableView and was instead using a tableview that I had created and added through code in my ViewController. Therefore the "Scene Exit" that I hooked up to the UITableViewCell on my storyboard was never being called (because the UITabelViewCell that it was hooked up to was not the one that was visible when the app ran)
I simply created an outlet to the table view and used that and all was fine. I'll put it down to my newbie status :-/

Related

iOS: Very Simple Segue Not Working

Starting with an empty project here...
If I make a UITableViewController and make a segue from a prototype cell to some other UIViewController using the Ctrl + Click method, nothing happens. It is of the modal variety.
If I use the same method to segue from a navigation bar button it works just fine, but when I run the iOS simulator I can't even select the table cell. It's just completely unresponsive.
I was under the impression that I don't need to write any code for a simple segue such as this to work, is this false?
Edit: Fixed the issue. For those as new as I, remember to make sure "selection" is enabled in the TableView, AND TableCell Attributes windows.
On the Storyboard, Right click on the prototype cell and Under "Triggered Segues", from "selection" make your segue to desired Viewcontroller
For me, this was a combination of:
making sure I was subclassing UITableViewCell,
making sure the Segue had an identifier assigned to it in the Attributes Inspector, and
I was setting a reuse identifier for my subclassed UITableViewCell in the Storyboard's Attributes Inspector (NOT programmatically).
Did you set your cell to static?
Also have a look in this amazing tutorial in how to archive what you are looking for.

Segue in UICollectoinView using Xcode 6

I am new to Swift and iOS development.
I am trying to create a demo app which simply shows details of an item in a new scene when clicked.
I tried using Storyboard but I learned that One cannot create segues directly from cells in a storyboard because the CollectionView is populated dynamically through the data source.
So I tried using performSegueWithIdentifier:sender but clicking an item doesn't trigger anything. I have set the Identifier for the Segue in Storyboard. I can't figure out what's wrong (As I am pretty new and don't understand the complete flow yet).
My first class is myFirstViewController.swift and second is mySecondViewController.swift
Please help (Where should I put the prepareForSegue, performSegue function?)
I am using xCode 6 on OS X Yosemite.
Your myFirstViewController class must implement the UICollectionViewDelegate protocol.
In InterfaceBuilder create a segue to your second viewController by ctrl-dragging from the viewController1 icon to the second viewController. Give that segue an identifier name in the property inspector.
In myFirstViewController.swift, implement the collectionView(_:didSelectItemAtIndexPath:), there you can call performSegueWithIdentifier with your segue's identifier name.
You can segue directly from a cell in storyboard. Simply right-click and drag from the cell in the storyboard to the detail view controller that you want to activate.
If you really don't want to do it that way. Then another option would be to right-click and drag from your main view controller to the detail view controller to create a generic segue. Then name the segue. After that, you can call perform segue in your collectionView(collectionView, didSelectItemAtIndexPath) method. (Make sure you connect your view controller to your collection view as a delegate for this method to get called.)
Either way, you need to write a prepareForSegue(segue, sender) method in your main view controller to pass the selected item to the detail view controller.
Good luck on your new learning adventure!

Segue between multiple detail views when selecting from tableview

Ok, I haven't been able to find a definitive answer to this. I'm on Xcode 6 working with Swift and a UISplitView. I have multiple detail views in storyboard and I want to be able to replace my detail view with another when selecting from a tableview. In Xcode 5, I was able to drag multiple segues from my prototype cell and use performSegueWithIdentifier. In Xcode 6, I can only have one segue coming from my prototype cell.
What's the best way to go about this?
One type of cell, one segue. This seems to be a logical and useful system constraint.
One solution is to just create more cell types with different cell identifiers.
Alternatively, if you have another way to determine which segue to use, draw all segues from the view controller instead of the cell. You can attach the necessary row object information in the sender object when calling the segue from the cell selection method.
You can create as many segues as u want from viewcontroller and give each seuge an different segue Identifier in IB, and the call each with performSegueWithIdentifer method

iOS UITableView: didSelectRowAtIndexPath not reacting for clicks everywhere

I have several UITableViews which should segue further in my navigation controller. First I've created the segues directly from the table view cells. But then I've noticed that in the smaller cells if you click on the label or somewhere, this method didSelectRowAtIndexPath doesn't get triggered. Only if you click on an "empty" space in the cell.
So I've created the segue for the whole view and just called performSegueWithIdentifier in the didSelectRowAtIndexPath method.
But still the same problem. Is this only my impression that you have to click on empty parts or onto the right side of a cell to perform a segue or is something else wrong? Or how could I make the whole cell reactive?
You might try turning off User interaction enabled for the labels in your cell.

Push Detail View from UITableView only on a specific UIImage in the cell?

I've got a UITableView which pushes a detail view when I tap any of its cells. I'd like that segue to only occur when tapping a specific part of the cell, a UIImageView at its left side. Tapping the rest of the cell should trigger a UITapGestureRecognizer which triggers a different method.
How can I override the default tap on the UITableViewCell, so that simply tapping anywhere on the cell doesn't trigger the segue to the detail view? I still want that transition, just only triggered by the UIImageView.
I think you could achieve that by connecting the segue with the image in the prototype cell (Never tried that myself) and not with the table view.
If you don't have a prototype cell then you should programmatically invoke an IBAction type of method with the image views. Well, Image Views cannot do that. Simply abuse a UIButton of the same size, custom style and assign the image to that button. Works fine.
(It does not need to be an -(IBAction) type of method, but it does not harm and doing so ensures that everything works fine.)
Within that action method invoke the segue programmatically. The segue needs to have an ID for that which is unique within the storyboard.

Resources