Passing information between UICollectionViewControllers through unwind segues

时间:2015-07-29 00:10:08

标签: ios swift uistoryboardsegue

I have two UICollectionViewControllers and the first one uses a push segue to get to the second one. The problem I'm having is passing information back to the first controller when the back button (the one that gets added automagically) is pressed in the second controller. I've tried using the $('#your-modal-id').modal('hide'); $('body').removeClass('modal-open'); $('.modal-backdrop').remove(); , and segueForUnwindingToViewController override functions, but no dice. I need to be able to access both view controllers so I can set some variables. Any ideas?

2 个答案:

答案 0 :(得分:0)

Here is an example with two view controllers. Let's say that the names of the two view controllers and ViewController and SecondViewController. Let's also say that there is an unwind segue from the SecondViewController to the ViewController. We will pass data from the SecondViewController to the ViewController. First, let's set the identifier of this segue by opening the document outline and selecting the unwind segue. Then open up the attributes inspector and set the identifier to "unwind".

enum ConditionType
{
     CONDITION_QUESTVALUE;
};

struct Condition
{
public:
    OperatorType operatorType;
    int intParams[5];
    ConditionType type;
};

答案 1 :(得分:0)

It sounds like you are trying to intercept the back button, there are many posts for this on SO, here are two:

Setting action for back button in navigation controller

Trying to handle "back" navigation button action in iOS

In practice, it is more clear to return state in closures (more modern), or delegates.