3

I have two different push perform in view controller as below:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  

     indexPathRow = indexPath.row;  

     NSLog(@"indexPathRow.%d", indexPathRow);  

    safetyInventoryList.recordIdToEdit = [DeviceIdArray objectAtIndex:indexPathRow] intValue];  

    NSLog(@"Item selected..%d", inventoryList.recordIdToEdit);  

    [self performSegueWithIdentifier:@"DetailsViewController" sender:nil];  

}  



 -(IBAction)ViewScoreBtn:(id)sender {  

     [self performSegueWithIdentifier:@"ScoreViewController" sender:nil];  

 }  

I get the following error and black screen when i click back button after entering "viewscore" button -> VC.

nested push animation can result in corrupted navigation bar  
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.  
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't add self as subview'  

Updated code:in prepare for segue I have following (in my presenting VC):(.m)

 if([segue.identifier isEqualToString:@"ScoreViewController"]){  
        ScoreViewController *destViewController = segue.destinationViewController;  
        destViewController.delegate = self;  
    }  

and

 - (void)dismissScoreViewController:MVVMScoreViewController{  
    [self dismissViewControllerAnimated:YES completion: nil];  
 }  

in my presented VC(.h &.m):

@protocol dismissScoreDelegate <NSObject>  

 - (void)dismissScoreViewController:SafetyDeviceViewController;  

@end  
 @property (nonatomic, assign) id<dismissScoreDelegate> delegate;  

 -(void) viewWillDisappear:(BOOL)animated {
    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
        // Navigation button was pressed. Do some stuff
        [self.delegate dismissScoreViewController];
     }
   [super viewWillDisappear:animated];
 }  

So what's going wrong?

Smitha
  • 5,956
  • 19
  • 87
  • 150
  • possible duplicate of [Dismissing a Presented View Controller](http://stackoverflow.com/questions/14636891/dismissing-a-presented-view-controller) – Khaled Barazi Nov 23 '14 at 06:21
  • Sorry, I am new to iOS and I did not get it completely. – Smitha Nov 23 '14 at 06:31
  • I suggest you read up Apple documentation on View controllers: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog – Khaled Barazi Nov 23 '14 at 06:45

2 Answers2

0

1.comment the perform segue that cause this error

2.run the project

3.tap the button/action from where it is intended to perform the navigation

4.Check for the duplication or multiple segue perform.

i got this due to the multiple segue activity from single button action.

0

Use unwind segue instead of pop , it will work fine

divya d
  • 173
  • 7