dismissViewController: funktioniert nicht

Ich habe einen view-controller genannt vc0, welches wie dieses:

[self presentViewController: vc1 animated: YES completion: nil];

Und in vc1 habe ich einen button zu präsentieren, ein weiteres view-controller:

[self presentViewController: vc2 animated: YES completion: nil];

Dann in vc2, ich habe eine Schaltfläche zum schließen des view-controller:

[self dismissViewControllerAnimated:YES completion: ^{
//over here I call one method in vc1
}

Und wie erwartet gibt es zurück an vc1.. aber es ist eine Schaltfläche, die in vc1 zurück zu gehen, um vc0 durch schließen des view-controller wie diesem:

    [self dismissViewControllerAnimated:YES completion:nil];

Aber aus irgendeinem Grund funktioniert es nicht, die view-controller nicht entlassen, zurück zu vc0. Wenn ich zunächst vc1, kann ich drücken Sie die Schaltfläche zum schließen des view-controller und es funktioniert. Aber wenn ich auf den Knopf drücke zum öffnen vc2, und wenn ich entlassen vc2 zurück, vc1, und DANN drücke ich die Taste zum schließen des view-controller, das ist, wenn es nicht funktioniert.

Sorry, wenn die Frage ist ein bisschen unklar, es ist ein bisschen schwer zu formulieren, was ich zu sagen versuche.

Auch eine weitere Sache:

Ich versucht, anstelle dismissViewControllerAnimated: im vc1 manuell zu präsentieren vc0, aber dann bekomme ich ein log in der Konsole zu sagen, dass ich versucht bin, eine vc0, aber vc1 ist der Ansicht, nicht in die Fenster-Hierarchie. Was bedeutet das?

Danke für die Hilfe!

UPDATE:

IN DIESEM FALL VC0 IST MenuMileIndexViewController - VC1 IST FlightViewController - VC2 IST BookmarksTableViewController

Hier ist der code eingebunden:

MenuMileIndexViewController:

- (IBAction)goToOriginPage {

FlightRecorder *origin = [[FlightRecorder alloc] init];
[self presentViewController:origin animated:YES completion:nil];

}

Flight Recorder:

    - (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;
        }
    }

}

BookmarksTableViewController:

    - (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];
    }];
}

NUN, habe ich eine Bildschirm Aufnahme der app in den simulator, der zeigt, was das problem ist. Ich kann E-Mail, dass Sie sich für die Referenz. So kann ich E-Mail, dass Sie.

schreiben Sie die Konsole-Meldung
wie und wo werden Sie die Aktion für die Schaltfläche?
In der xib-Datei
1. "Was hat das zu bedeuten?": Es s weil Sie erstellen eine neue Instanz von vc0, indem Sie "manuell vorhanden vc0". 2. Was tun Sie mit "// hier rufe ich eine Methode in vc1"?

InformationsquelleAutor MCKapur | 2012-09-29

Schreibe einen Kommentar