Unind segue / performSegueWithIdentifier: problems

my application has a chat service. when a user wants to inform someone new, he clicks on the “new chat” and the screen controller of the table is displayed, which is selected from the list of friends. I use unind segues to go back to the previous view controller and share the data between the two view controllers (basically, the data will be friends to chat with). unwinding segue works fine, however, in my application, when the user returns to the main VC, I start a new session to go to another VC directly, where the user has chat; and it does not work. All segments are well connected, and I tried NsLog in every corner, and it got there, and even to readyForSegue: it is accessed. I tried to put NsTimer, thought there might be some technical conflict,and it didn’t work. I change segue to VC chat for modal, and now it gives me this error:

A warning. Try to imagine whose view is not in the hierarchy of windows!

I can access this VC in other ways and in a hierarchy. my questions are: what could be wrong? does reversal segues change window hierarchies?

PICTURE: enter image description here

To present the problem more visually, the main VC that I am talking about is located at the bottom left connected to the navigation view controller. when a user clicks on a new chat, two VCs are displayed in the upper right corner (one of them is between friends or a group, the other is for friends / groups). therefore, when a friend is selected to say from the top right VC, I have to unwind the segue to the main VC. as you can see from the main VC, there are other segments. not one of them can work if I unwind segue, and they work if I work normally.

+4
4

, , , , .

, , , , segue , , , , , NSLog , :

2013-11-27 14:51:10.848 testUnwindProj[2216:70b] Unwind
2013-11-27 14:51:10.849 testUnwindProj[2216:70b] Will Appear
2013-11-27 14:51:11.361 testUnwindProj[2216:70b] View Did Disappear

, , ( ), . :

@interface ViewController () {
    BOOL _unwindExecuted;
}

@end

@implementation ViewController

- (void)viewWillAppear:(BOOL)animated
{
    NSLog(@"Will Appear");
    if (_unwindExecuted) {
        _unwindExecuted = NO;
        [self performSegueWithIdentifier:@"afterunwind" sender:self];
    }
}

- (IBAction)unwind:(UIStoryboardSegue *)segue
{
    NSLog(@"Unwind");
    _unwindExecuted = YES;
}
+14

, , .

: - (void) cancelViewControllerAnimated: (BOOL) : (void (^) (void))

, VC. , , segues, , .

, UIViewController viewDidAppear.

+2

, , , , .

, segueIdentifierToUnwindTo .

JAManfredi, , .

@interface FirstViewController ()
// Use this to coordinate unwind
@property (nonatomic, strong) NSString *segueIdentifierToUnwindTo;
@end

@implementation FirstViewController
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];   
    // Handle unwind
    if (_segueIdentifierToUnwindTo) {
        [self performSegueWithIdentifier:_segueIdentifierToUnwindTo sender:self];
        self.segueIdentifierToUnwindTo = nil;   // reset
        return;
    }
    // Any other code..
}

// Example of an unwind segue "gotoLogin"
- (IBAction)gotoLogin:(UIStoryboardSegue*)sender {
    // Don't perform segue directly here, because in unwind, this view is not in window hierarchy yet!
    // [self performSegueWithIdentifier:@"Login" sender:self];
    self.segueIdentifierToUnwindTo = @"Login";
}
@end

, unind segues FirstViewController : http://samwize.com/2015/04/23/guide-to-using-unwind-segues/

+2
source

Okay, solve this, the problem is that there was no view yet, and I had to postpone the process as follows:

[self performSelector:@selector(fireNewConv) withObject:nil afterDelay:1];

However, something interesting is that I tried to delay NSTimer, but it did not work.

-2
source

All Articles