0

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.

Luuk D. Jansen
  • 4,402
  • 8
  • 47
  • 90
  • 1
    The **one** line of code you posted doesn't tell us anything that would allow us to help you. Please give us more information. Such as where the FRC lives and what its relationship is to showing a `SFSafariViewController`. – Avi Dec 15 '15 at 10:39
  • Not sure I understand "not all provide a SSL connection. So I needed to implement a SFSafariViewController to show the website". – jcaron Dec 15 '15 at 10:42
  • It is not possible to show non secure content in an UIWeb in iOS 9 (unless you override it). I could override it, but that would only be a temporary solution I would expect. – Luuk D. Jansen Dec 15 '15 at 11:17
  • I added some more information regarding the application structure. – Luuk D. Jansen Dec 15 '15 at 11:27
  • You have not provided us with **any** relevant code, just a few declarations with lots of variables that seem to be completely irrelevant to the issue. Please provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – jcaron Dec 15 '15 at 11:57

0 Answers0