Is there a way to hide Back to Safari from status bar in iOS9?
No, there is no API that lets you do this.
At SFSafariViewController dismiss, disable status bar hide animation [iOS 9]
Just found the solution:
If i create and present SFSafariViewController
with:
#import <SafariServices/SafariServices.h>
SFSafariViewController *sfc = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:@"http://google.com"]];
sfc.delegate = self;
[self presentViewController:sfc animated:YES completion:nil];
Implementing the delegate ( SFSafariViewControllerDelegate
) method:
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
The VC is presented beautifully without status bar! And doesn't make a bad effect during dismiss.
Implementing just the delegate method works perfectly even with a SFSafariViewController
called by Facebook SDK (4.6.0 from CocoaPods)
EDIT:
Doing other tests, looks like the delegate method doesn't work as expected;
But just implementing:
View controller-based status bar appearance : FALSE
In the .plist file is enough to hide the status bar in a SFSafariViewController
Remove back to safari button in Swift iOS 9
This is an iOS 9 Feature that you cannot and should not hide.
SFSafariViewController: Hide navigation bar
Put this code in viewDidAppear:
let safariViewController = SFSafariViewController(URL: url)
presentViewController(safariViewController, animated: true) {
var frame = safariViewController.view.frame
let OffsetY: CGFloat = 64
frame.origin = CGPoint(x: frame.origin.x, y: frame.origin.y - OffsetY)
frame.size = CGSize(width: frame.width, height: frame.height + OffsetY)
safariViewController.view.frame = frame
}
To hide the status bar, set View controller-based status bar appearance
to YES
in your info.plist file and insert this in your view controller.
override func prefersStatusBarHidden() -> Bool {
return true
}
Warning: I will suggest you against using SFSafariViewController for full screen view because reloading is not possible(since reload button is in UINavigationBar). In case request fails, it will render the application useless.
Rather go for full screen WKWebView with custom toolbar instead.
Update:
To avoid hiding the reload button, just add a view/imageView over the done button in your SFSafariViewController and render button invisible or at least untappable.
presentViewController(svc, animated: true) {
let width: CGFloat = 66
let x: CGFloat = self.view.frame.width - width
// It can be any overlay. May be your logo image here inside an imageView.
let overlay = UIView(frame: CGRect(x: x, y: 20, width: width, height: 44))
overlay.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.5)
svc.view.addSubview(overlay)
}
The problem with this approach is only that overlay stays on screen, but if you can find a nice image for it, you will be fine.
Swift + Parse: Facebook login flow has Back to Safari in iOS9
As this reply is too long to put it in the comment textField:
I used this techniques in one of my apps.
In AppDelegate
write this method for example:
func buildUserInterface(){
let objectID:String? = NSUserDefaults.standardUserDefaults().stringForKey("user_id")
if objectID != nil {
let mainStoryBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let singleMode:singleModeVC = mainStoryBoard.instantiateViewControllerWithIdentifier("singleModeVC") as! singleModeVC
let mainPageNav = UINavigationController(rootViewController: singleMode)
let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = mainPageNav
}
}
It can therefore only be used, when you got a user logged in or just created.
In the ViewController
handling the regristration/loggin in within the Login Block put this:
if PFUser.currentUser() != nil {
objectID = PFUser.currentUser()?.objectId
NSUserDefaults.standardUserDefaults().setObject(objectID, forKey: "user_id")
NSUserDefaults.standardUserDefaults().synchronize()
// singleModeVC
let mainStoryBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let singleMode:singleModeVC = mainStoryBoard.instantiateViewControllerWithIdentifier("singleModeVC") as! singleModeVC
let mainPageNav = UINavigationController(rootViewController: singleMode)
let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = mainPageNav
singleModeVC is the name and class of my view controller to appear after signing in. Hope it helps.
Related Topics
Xcode Creates Wrong IPA Folder Structure
Uisegmentedcontrol iOS 13 Clear Color
Fbsopenapplicationerrordomain Code=3
Rotate Image Using Cgcontextdrawimage
How Could You Make a Uilabel Wrap Around an Image (Like Shown)
Convert Spelled Out Number to Number
Store Time Efficiently in Firebase Database
Ld: Framework Not Found Stripe for Architecture X86_64
How to Solve This Exc_Bad_Access(Code=Exc_I386_Gpflt )In Swift Programming
Cannot Assign Class Instance to Its Protocol Type
How to Recover After I Execute :Git Reset --Hard Head
How to Show Specific Language Keyboard When User Input Values in Uitextfield in iPhone App
Why Was Uitextfield's Text Property Changed to an Optional in Swift 2
Chrome for iOS User Agent on iPad
Hide Status Bar and Increase the Height of Uinavigationbar
Implementing Autocomplete in iOS