Note that there are some explanatory texts on larger screens.

plurals
  1. POdismissViewController: not working
    primarykey
    data
    text
    <p>I have a view controller called vc0 which is presented like this:</p> <pre><code>[self presentViewController: vc1 animated: YES completion: nil]; </code></pre> <p>And in vc1 I have a button to present another view controller:</p> <pre><code>[self presentViewController: vc2 animated: YES completion: nil]; </code></pre> <p>Then in vc2, I have a button to dismiss the view controller:</p> <pre><code>[self dismissViewControllerAnimated:YES completion: ^{ // over here I call one method in vc1 } </code></pre> <p>And as expected it returns back to vc1.. however there is a button in vc1 to go back to vc0 by dismissing the view controller like this:</p> <pre><code> [self dismissViewControllerAnimated:YES completion:nil]; </code></pre> <p>But for some reason it doesn't work, the view controller does not get dismissed back to vc0. When I first present vc1, I can press the button to dismiss the view controller and it works. But when I press the button to open vc2, and when I dismiss vc2 back to vc1, and THEN I press the button to dismiss the view controller, that is when it doesn't work.</p> <p>Sorry if the question is a bit unclear, it is a bit hard to phrase what I am trying to say.</p> <p>Also one more thing:</p> <p>I tried replacing <code>dismissViewControllerAnimated:</code> in vc1 to manually present vc0, but then I get a log in the console saying that I am trying to present a vc0 but vc1's view is not in the window hierarchy. What does this mean?</p> <p>Thanks for help!</p> <p>UPDATE:</p> <p><strong>IN THIS CASE VC0 IS <code>MenuMileIndexViewController</code> - VC1 IS <code>FlightViewController</code> - VC2 IS <code>BookmarksTableViewController</code></strong></p> <p>Here is code involved:</p> <blockquote> <p>MenuMileIndexViewController:</p> </blockquote> <pre><code>- (IBAction)goToOriginPage { FlightRecorder *origin = [[FlightRecorder alloc] init]; [self presentViewController:origin animated:YES completion:nil]; } </code></pre> <blockquote> <p>Flight Recorder:</p> </blockquote> <pre><code> - (void)searchBarBookmarkButtonClicked:(UISearchBar *)searchBar { [self bringUpBookmarkkTable]; } - (void) bringUpBookmarkkTable { BookmarkTableViewController *bookmarkTVC = [[BookmarkTableViewController alloc] init]; [bookmarkTVC setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal]; [self presentViewController:bookmarkTVC animated:YES completion:nil]; } - (IBAction)cancel { [self dismissViewControllerAnimated:YES completion:nil]; } - (void)endBookmarkProcessWithBookmarkCollection: (NSDictionary *)dict { presetBookmarkContext = [dict mutableCopy]; bookmarkMode = YES; NSString *compiledText = nil; NSNumber *number1 = [NSNumber numberWithInt: 1]; if ([dict objectForKey: @"bookmarkTag"] == number1) { compiledText = [NSString stringWithFormat: @"%@ to %@", [dict objectForKey: @"origin"], [dict objectForKey: @"destination"]]; } else { compiledText = [NSString stringWithFormat: @"%@ to %@", [dict objectForKey: @"destination"], [dict objectForKey: @"origin"]]; } compiledText = [compiledText stringByReplacingOccurrencesOfString:@"Origin: " withString:@""]; compiledText = [compiledText stringByReplacingOccurrencesOfString:@"Destination: " withString:@""]; flightContext = [NSDictionary dictionaryWithObjectsAndKeys: [dict objectForKey: @"miles"], @"miles", compiledText, @"location", [[NSUserDefaults standardUserDefaults] objectForKey: @"tempD"], @"date", nil]; NSString *string = [NSString stringWithFormat: @"\nMiles: %.2f\nFlight: %@\nDate: %@", [[dict objectForKey: @"miles"] floatValue], compiledText, [[NSUserDefaults standardUserDefaults] objectForKey:@"tempD"]]; UIAlertView *bvkBookmarkAlertView = [[UIAlertView alloc] initWithTitle:@"Confirmation" message:string delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil]; [bvkBookmarkAlertView show]; } - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { [self cancel]; // Even though cancel is an IBAction, IBAction is the same thing as void so it is callable } } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { [TheMileIndexViewController addDesiredMilesToIndex: [[flightContext objectForKey: @"miles"] doubleValue]]; [TravelLogViewController addFlight: flightContext]; if (!bookmarkMode) { if ([checkbox isSelected]) { [BookmarkHandler uploadBookmark: bookmarkFlightContext]; } } } if (buttonIndex == 0) { if ([alertView.title isEqualToString: @"Confirmation"]) { bookmarkMode = NO; } } } </code></pre> <blockquote> <p>BookmarksTableViewController:</p> </blockquote> <pre><code> - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated: YES]; NSDictionary *dict = [[BookmarkHandler bookmarkCollection] objectAtIndex: indexPath.row]; fl = [[FlightRecorder alloc] init]; [self dismissViewControllerAnimated:YES completion:^{ [fl endBookmarkProcessWithBookmarkCollection: dict]; }]; } </code></pre> <p>NOW, I have created a screen recording of the app in simulator showing what is the problem. I can email that to you for reference. So I can email that to you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload