1

I am presenting a Safari view controller when a row is selected in my table view. Once I'm done with the Safari view controller I press the done button and it returns me to my table view. I'm having an issue when I swipe to the right to dismiss the Safari view controller. If I swipe to dismiss instead of pressing done, I can still scroll my table view and reload it, but I can't select a row. It's my understanding that if the Safari view controller still exists, another one cannot be presented until the first one is really gone. It seems that this may be what is causing the issue. How can I make the swipe to dismiss the Safari view controller actually get rid of the presented controller?

    func safariViewControllerDidFinish(controller: SFSafariViewController) {
            controller.dismissViewControllerAnimated(true, completion: nil)
        }

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
            var linkString = posts.objectAtIndex(indexPath.row).valueForKey("link") as? String
            linkString = linkString!.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())
            linkString = linkString?.stringByReplacingOccurrencesOfString("%09%09", withString:"")
            let url = NSURL(string: linkString!)
            let safariVC = SFSafariViewController(URL: url!, entersReaderIfAvailable: true)
            safariVC.delegate = self
            let kfbBlue = UIColor(red: 8.0 / 255.0, green: 77.0 / 255.0, blue: 139.0 / 255.0, alpha: 1.0)
            safariVC.view.tintColor = kfbBlue
            self.presentViewController(safariVC, animated: true, completion: nil)
        }
raginggoat
  • 3,570
  • 10
  • 48
  • 108
  • i think your class should conform to [SFSafariViewControllerDelegate](https://developer.apple.com/library/prerelease/ios/documentation/SafariServices/Reference/SFSafariViewController_Ref/index.html#//apple_ref/occ/instp/SFSafariViewController/delegate) and set the `delegate` property of the SVC. Simply dismiss the VC from the `safariViewControllerDidFinish:` callback – lootsch Mar 08 '16 at 13:17

0 Answers0