2016-09-23 7 views
0

私のアプリのユーザーを認証するためにSafari Cookieを使用したいと思います。私はSFSafariViewControllerでそれを行うことができます。しかし、問題はいくつかの情報を表示する私のアプリでUIWebViewを持っている。ユーザーはSafariを使用してログインしていても、UIWebViewから再びログインするように求められます。私はこれを同期したい。ユーザーがサファリでログインしている場合は、app.Iで再びログインする必要はないはずです。サファリとuiwebviewはCookieを共有していないので、すべてをサファリに移動したいと思っています。ビューコントローラ内にサファリを表示することは可能でしょうか?UIWebviewのようなViewController内でSafariViewControllerを使用する

おかげで、 Richa

答えて

0

PopoverViewController方法

let vc = SFSafariViewController(url: URL, entersReaderIfAvailable:false) 
    vc.modalPresentationStyle = .popover 
    vc.preferredContentSize = CGSize(width: self.view.frame.width/2, height: self.view.frame.height/2) // Or put any size 
    if let popover = vc.popoverPresentationController { 
     popover.sourceView = self.view // You can also put the source button 
     popover.permittedArrowDirections = .any 
     popover.sourceRect = CGRect(x: 0, y: 0, width: 85, height: 30) 
     popover.delegate = self 
     self.present(vc, animated: true, completion: nil) 
    } 

次にこのサブクラス宣言:

class ViewController: UIViewController, UIPopoverPresentationControllerDelegate 

をしかし、これはiPad用の唯一の作品ですので、この置く:

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle { 
    return .none 
} 

Result

関連する問題