I am showing webpages linked to article in my App, and not all provide a SSL connection. So I needed to implement a SFSafariViewController to show the website.
On my iPad interface I manually add views to the mainController, but if I try to add the view of the SFSafariViewController I get nothing.
So I tried to use:
[[[self parent] navigationController] presentViewController:webView animated:YES completion:nil];
However, while this work very nicely, for some reason my datasource returns 'nil' objects afterwards. Even if I retain a strong link to the object in the view calling presentViewController.
My work around is to dismiss all views I have open, reload my dataset when the SFSafariViewController is dismissed, but this is not nice for the user experience as the user has to navigate the whole way back to where they were.
I am completely in the dark why my NSFetchedResultsControllers are all returning 'nil' after the launch of the SFSafariViewController. Any hints would be very much appreciated.
[EDIT:] This is the declaration of my main view controller. The iPad controller calls on this controller when launching the SFSafariViewController:
@interface DOMainViewController : UIViewController <UINavigationControllerDelegate> {
id <DOActionControllerProtocol> _actionController;
MPMoviePlayerViewController* _moviePlayerViewController;
UINavigationController* _navigationController;
}
Calling the SFSafariViewController (where parent is the DOMainViewController):
SFSafariViewController* webView = [[SFSafariViewController alloc] initWithURL:link];
[webView setDelegate:self];
[[[self parent] navigationController] presentViewController:webView animated:YES completion:nil];
The DOiPadController definition is as follows, where the s=views which re shown are stored in _viewControllers.
@interface DOiPadActionController : NSObject <DOActionControllerProtocol, SFSafariViewControllerDelegate> {
@private
DOMainViewController* __weak _parent;
NSMutableArray* _viewControllers;
NSMutableArray* _oldViewControllers;
int _firstViewX;
int _previousTranslation;
CGPoint _translatedPoint;
bool _bouncedLeft;
bool _bouncedRight;
bool _overruleBounce;
//Need to be able to enable and disable.
UIPanGestureRecognizer *_panRecognizer;
}
I release view controllers from there when not needed anymore, and add new ones when needed. This allows views to be sliced out of view etc.
In the iPhone App I use the navigation controller for my views, and there there seems no problem.