Frage

Ich kann keine logische Erklärung finden, aber die Tatsache bleibt, dass in iOS 5 (Xcode 4.2), wenn ich modalview:* animiert: Ja, ich kann DELDELMODALVIEWArimated nennen:* Gut, aber wenn ich präsent modalview nenne:* animiert: nein Anschließend die Entlassungsmethode abfällt. (Dies funktioniert gleich, wenn ich den neuen PresentViewController verwende: Animated: Fertigstellung: + dishellViewControlleranimated :). Ich werde versuchen, das vorerst zu arbeiten (ich möchte nicht, dass die Präsentation animiert ist) und Apple einen Fehler melden, aber ich habe meinen Kopf schon eine Weile geschlagen. Alle Vorschläge sind willkommen. Auf iOS 5 nicht viel da draußen, also helfen Sie bitte, wenn Sie können. Beispielcode, der in iOS 4 oder iOS 5 nicht abstürzt:

LoginController *loginController = [[LoginController alloc] initWithNibName:@"LoginControllerGG" bundle:nil];
[self presentModalViewController:loginController animated:YES];
[loginController release];
...
[self dismissModalViewControllerAnimated:YES];

Dies wird in iOS 5 mit EXC_BAD_ACCESS auf dem Entlassungsanruf abstürzen:

LoginController *loginController = [[LoginController alloc]    initWithNibName:@"LoginControllerGG" bundle:nil];
[self presentModalViewController:loginController animated:NO];
[loginController release];
...
[self dismissModalViewControllerAnimated:YES]; //crashes with EXC_BAD _ACCESS

Ein Hinweis: Ich habe eine Animation innerhalb des Logincontroller, der auf ViewDidload stattfindet. Ich werde sehen, ob sich das etwas verändert, aber ich wollte das herausholen, da ich so schnell wie möglich eine Lösung benötige.


Bearbeiten] Voller Codefluss ... in AppDelegate, Anwendung: didfinishlaunchingwithOptions:

if (!loggedIn)  [myViewController showLoginPanel];

In myviewController:

- (void)showLoginPanel {    
    LoginController *loginController = [[LoginController alloc] initWithNibName:@"LoginControllerGG" bundle:nil];
    if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) {
        [self presentViewController:loginController animated:NO completion:nil];
    } else {
        [self presentModalViewController:loginController animated:NO]; //iOS 4 works fine with or without animation   
    } 
    [loginController release];  
}

In Logincontroller:

- (IBAction)closeLoginWindow {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"CloseLoginWindow" object:nil];
}   //doing it this way because calling on the self.parentViewController doesn't work

Zurück in myviewController:

- (void) viewDidLoad
    ...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeLoginWindow) name:@"CloseLoginWindow" object:nil];
    ...

- (void)closeLoginWindow {
    if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
        [self dismissViewControllerAnimated:YES completion:nil];    //iOS 5 crashes only if presentation was not animated
    } else [self dismissModalViewControllerAnimated:YES];    //deleting the previous condition, iOS 5 still crashes if presentation was not animated
}    
War es hilfreich?

Lösung

In iOS5 hat sich die Verwaltung der Lebenszylinder irgendwie geändert, und ich kann dieses Problem nicht im Detail erklären. Wie auch immer, die Lösung besteht darin, diesen Workflow von applicationDidfinishlaunching -withOptions auf applicationDidbeComeActive zu verschieben. Es scheint, dass etwas mit dem Aufruf von ApplicationDidfinishlaunching -WithOptions nicht initialisiert wird.

- (void)applicationDidFinishLaunchingWithOptions:... {    
    // in order to do this only at launching, but not on every activation 
    // Declaration as property for example
    applicationDidLaunch = YES;
}

- (void) applicationDidBecomeActive:(UIApplication *)application {
    if (applicationDidLaunch) {
        applicationDidLaunch = NO;
        [Start your login Workflow with modal view presenting here]
    }
}

Neugierig auf dein Feedback :) ....

Andere Tipps

Ich werde meine 2 Cent hinzufügen: Ich hatte ImagePickerController und ließ seine Entlassung erst funktionieren, wenn ich den Auswahl nicht manuell veröffentlicht habe (iOS 5 SDK).

So. Für Ihren Fall könnte ich eine solche Problemumgehung anbieten: 1. Zeile entfernen - [Logincontroller -Release]; 2. Um Speicherlecks zu verhindern, fügen Sie Ihrem aktuellen Controller einen Logincontroller als Eigenschaft hinzu und geben Sie ihn nur in Dealloc () des aktuellen Controllers frei:

@interface myViewController : UIViewController 

@property (nonatomic, retain) LoginController *loginController;

@end

...

@implementation myViewController

- (void)showLoginPanel {    
    self.loginController = [[LoginController alloc] initWithNibName:@"LoginControllerGG" bundle:nil];
     // ... something goes here  
}

-(IBAction)loginClose() 
{
    // this should close all windows as far as you call it from current (main) controller
    [self dismissModalViewControllerAnimated:YES]; 
    // ... then anything you want EXCEPT [loginController release];
}

-(void)dealloc() 
{
    [loginController release];
}

@end

Viel Glück :)

PS Ich habe das gerade geschrieben, also ist es nur eine Idee, wie man es betrügt. Ein bisschen kann mich korrigieren ... obwohl es für mich trotzdem funktioniert hat.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top