I have an UITabelViewController
(mainViewCtrl), if the user select a cell, a new UIViewController
(detailViewCtrl) is been pushed into the "Scene", with some detail data regarding the selected cell. - pretty simple stuff.
If the user Shakes the phone, (detailViewCtrl) will been showed with some random detail data.
Here is my prepareForSeque
code:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"DetailViewSeque"])
{
int i;
if ([sender isKindOfClass:[UITableViewCell class]]){
UITableViewCell *cell = (UITableViewCell*)sender;
NSIndexPath *indexPath = [self.minifigsTableView indexPathForCell:cell];
i = indexPath.row;
}else{
i = arc4random() % [self.collectionOfData count];
}
DeatilViewController *dest = [segue destinationViewController];
dest.data = [self.collectionOfData objectAtIndex:i];
}
}
The Code is pretty simple, nothing fancy. My problem is, if the user shakes the Phone while the transitions between the two ViewController (mainViewCtrl and detailViewCtrl) is going on, I will get this error:
Unbalanced calls to begin/end appearance transitions for.
I understand why this causes a problem.
But how do I solve it? How do I somehow stop the UIGestureEvent from been fired, while the transitions is active?
May be you can add a boolean property "isInTransit"
.
Set it to false
in your viewWillAppear
,
set it to true
in your prepareForSegue
(just up to your int i;
).
And in your motionEnded
(shake method) test if (isInTransit=true)
-> don't handle the shake, so don't fire the segue.
Hop this will help