Nested push animations iOS7 bug?

ぐ巨炮叔叔 提交于 2019-12-04 07:49:12

It's probably because you call two segues at the same time and when you release the buttons the app tries to call one segue before the other segue has finished.

So what I can see is that the warning that Xcode presents is because one of your view controllers is triggered by the segue and the other segue for the other view controller is triggered without waiting for the loading end of the first view controller.

You can try to set bool or some sort of controller that checks when the first view controller has loaded and then trigger your other segue when you know that the first view controller has loaded properly.

I was getting the same problem in my app by doing the following: 1 login (segue is performed with animation) 2 quickly make a selection on new screen (launches another segue)

if you try to perform a segue BEFORE the previous transition animation has completed, it can screw it up. So I added a delay before performing the segue and it seemed to fix it. however, I don't think this is a final solution because the segue animation duration can differ depending on how fast the device is.

I think the best solution would be to trigger the segue AFTER viewDidAppear.

I've just implemented something like that and it is now working.

So I have view controllers A, B & C. Normally users can navigate from A to B and from B to C but now I created a way that users can navigate from A to C (through B) automatically.

What I did was to create a public method in B saying to push C. This method looks like:

- (void)pushC {
    if ([self isViewLoaded] && self.navigationController.visibleViewController == self && ![self isBeingPresented] && self.didViewAppear) {
        [self performSegueWithIdentifier:@"CSegue" sender:self];
    }
    else {
        [self performSelector:@selector(pushC) withObject:nil afterDelay:0.4f];
    }
}

Everything is already given to you apart from that didViewAppear property. That one I set to true on - viewDidAppear.

Then I only need to call - pushC on the - prepareForSegue method in view controller A. As we've seen, he will wait for the right time to actually call the next segue.

This works alright but shows all the navigation transitions, which I don't need. I would prefer to be able to push a tree into the navigation controller so I would have only one transition navigation. Well, I guess I'll have to come back to this thing later.

This being said I don't think it's a bug but actually a change in behaviour in iOS7 because the animation got longer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!