Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-self parentViewController- dismissModalViewController not working on iOS 5

So, any clue on this? I had to use [self dismiss modalviewcontroller to dismiss modalviews. Funny fact: when dismissing a tabbarcontroller I could still use the reference to parentviewcontroller, when dismissing a regular viewcontroller, not.

like image 230
Stephen Lynx Avatar asked Oct 21 '11 12:10

Stephen Lynx


4 Answers

On iOS 5 you will need to use the presentingViewController selector instead of the parentViewController selector.

like image 137
Jason Avatar answered Nov 17 '22 16:11

Jason


-(UIViewController *)getParentViewController{   
    float currentVersion = 5.0;
    float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue];

    if (sysVersion >= currentVersion) {
        // iOS 5.0 or later version of iOS specific functionality hanled here 
           return self.presentingViewController;
    }
    else {
        //Previous than iOS 5.0 specific functionality
           return self.parentViewController;

    }
}
like image 21
UPT Avatar answered Nov 17 '22 16:11

UPT


The app i have in the store was built using ios SDK 4.3 and uses self.parentViewController dismissModalViewControllerAnimated:YES. It continues to work with IOS 5 devices. I thought it would since it was built on sdk 4.3. Now when i'm updating it with the new xcode and ios 5.0 sdk, it will not work as is and i have to change all the view closing stuff to use the conditional selector workaround mentioned above.(yuck!)

Just thought i'd mention that dismissing from the parent should work on ios 5 (at least in my case with the ios 4.3 sdk). I can't speak for previous sdks or other selectors with parentViewController.

like image 1
pterodax Avatar answered Nov 17 '22 17:11

pterodax


I have built a category that add presentingViewController on iOS 4.

It disables itself on iOS 5.

You can use it seamlessly. Please see backward-modal.

like image 1
Tanin Avatar answered Nov 17 '22 16:11

Tanin