dismissModalViewControllerAnimated: (and dismissViewControllerAnimated) crashing in iOS 5

前端 未结 2 1809
我寻月下人不归
我寻月下人不归 2020-12-31 14:31

I can\'t find any logical explanation, but the fact remains that, in iOS 5 (xCode 4.2), if I presentModalView:* animated:YES, I can call dismissModalViewAnimated:* fine, but

2条回答
  •  佛祖请我去吃肉
    2020-12-31 15:06

    I will add my 2 cents : i had ImagePickerController and got its dismissing working only when i did not release the picker manually (IOS 5 SDK).

    So. for your case i could offer such workaround : 1. remove line - [loginController release]; 2. to prevent memory leaks add loginController as a property to your current controller and release it only in dealloc() of current controller :

    @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
    

    Good luck :)

    P.S. I have just written this so it is just an idea how to cheat it. Somebosy may correct me ... though anyway it worked for me.

提交回复
热议问题