how to present a login, with UISplitViewController? - ios

I'm trying to build a universal iOS app. So, in Xcode I started with a Master-Detail template.
In the iPhone version of this, my first view is a list of items, and I have a "Logout" button in my Navigation Bar. When the user launches for the first time, a view-controller is presented, modally, on top of my normal "master" view. It just asks for a user/pass, lets the user log in. If the user hits the "Logout" button, some cleanup occurs, and then they are presented with the Login screen again.
On the iPad side of things, I'd like to have a UISplitViewController - as that interface matches well with what I'm trying to do. I'd like to do this in a similar fashion -- present the user with Login the first time they launch. Then later on, if they decide to leave the app, they can hit Logout, and be presented with Login options again.
I'd prefer to cover the entire screen with one view (just user/pass/login button), but am having trouble figuring that out, especially if the "master" view is visible.
So, the question is this: what is the preferred way to show a login screen, with a UISplitViewController in the mix, so that the user can't do anything else but login?

This really sounds like a personal choice/design decision.
You could have the "master" view be the login screen and have the "detail" be just a splash screen or cute kitten photo that says "please login"
You could also have a single UIView be the "initial" view page and have that segue into the splitview
I think you're quite open in the "how" of it so perhaps I'm not quite understanding your question.

Related

iOS Xcode Development with Segues full screen

I am new to iOS native development and have been struggling for a few days to understand some of the segue concepts. I have tried googling for that answer but I must not be using the terminology Apple has created for this.
I have inherited some code and I am trying to move from the login screen of my app to my first page in full screen. It moves to that page and gives the user that ability to swipe down and go back to the login screen. This is not the functionality that I want. I want to use a button to go back and not gesture functionality.
Assuming you created a "Present Modally" segue, select that Segue and, in the Attributes Inspector pane:
Select Full Screen from the Presentation drop-down.

Present a view controller just before the UIDocumentBrowserViewController to be shown at launch

Here are the facts: I have a document based app using iOS 11's UIDocumentBrowserViewController. And as noted in the documentation, I set it as my root view controller:
Always assign the document browser as your app's root view controller. Don't place the document browser in a navigation controller, tab bar, or split view, and don't present the document browser modally.
I have an animated launch screen in another view controller and in an usual app, it is the root controller. But here it can't be...
So my problem is that I can't achieve the smooth transition between the launch screen and the animated splash view controller.
I've tried to perform the segue unanimated to the splash in the viewWillAppear and in the viewDidLoad of the browser view controller... But between the launch screen and the splash screen, I have a glimpse of 1 second or two on the browser...
I even tried to present it over the browser view controller inside the applicationDidFinishLaunching but I have the same result...
So if anyone has a clean way of doing it, I'm interested. I would not like ending by inserting savagely views over the browser, if you see what I mean. 🤔
Thanks in advance.
Please watch the Managing Documents in your iOS apps WWDC session tomorrow. This restriction is about to get lifted. You can present the document browser modally full-screen over your splash screen, as long as you do not dismiss it afterwards (it needs to be at the "root" of your app for usability reasons). Don't forget to release any memory used by your splash screen once you present the browser.
However, I think a cleaner design would be to present your splash screen over the browser in viewWillAppear, as you suggest. If that doesn't work, could you please file a bug at bugreport.apple.com? Thanks.

How does the Air BnB achieve the user menu?

Using the air bnb app, if you click on the far right icon on the tab menu, it opens a user menu which slides in from the right over the top but only takes up half of the screen. The rest of the screen below is dimmed.
How can this be implemented? Does it require a custom segue or view controller container?
I have seen a similar feature to what your describing done before using a modal segue that instantiates a new view with a partially transparent background. You have given a vague question so I can't really provide a specific answer. Comment if you need more info.
Here is the app I saw it in, from a tutorial.

Direct to appropriate ViewController when user logs out/ is not logged in

I posted a similar question some time back, but it turns out the solution I chose is not sustainable nor a good one. So I'm trying again, with a different approach.
Here's my problem
I'm making an app that uses Facebook login and connects to a server. Therefore, at any given time, the user has to be logged in with Facebook and the user_id needs to be stored in the NSUserDefaults. If at any time in the app, any of the two is not present, I need to direct the user to a log-in screen.
In the same fashion, if the user manually presses log out, I need to direct him/ her to that same screen.
Seing that I'm using the SWRevealViewController, I need more than one UINavigationController. Therefore the popViewController does not work.
Here's my app setup
The initialViewController is a UINavigationController, pointing to another ViewController. In here, I check if the user is signed into Facebook and that the user_id is stored in the NSUserDefaults. If they are, I direct them to the SWRevealViewController. If they are not, I direct them to a LoginViewController (I use performSegueWithIdentifier:). From the LoginViewController, after the user is successfully signed into both Facebook and my servers, I direct them to the same SWRevealViewController.
Basically, the SWRevealViewController splits into two: A sw_front and a sw_rear (the menu). Each of those requires their own UINavigationController (as far as I know, I didn't get it to work without).
From here on, the app splits into several different ViewControllers.
You can see the storyboard in this image:
(Link to full-res image here)
(The logout button is the blue one on the top, the login is the blue one at the start)
Here's what I've tried:
The last time I asked a similar question, I chose to go with a solution where I present the InitialNavigationController using the presentViewController function when the user logs out. This seemed to work fine, and the new ViewController was presented modally which other apps seem to do as well (see linkedIn and more).
However, when I proceeded to log in again, the Facebook showLoggedInUser method seemed to be called twice (I placed a NSLog() statement in there). When I repeated a third time, it ran three times. Fourth login, four times, and so on.
In addition, on the second logout, I would get a warning in the compiler saying Warning: Attempt to present <UINavigationController: 0x13c566730> on <UINavigationController: 0x13c549c70> whose view is not in the window hierarchy!. This warning would also keep incrementing as I repeated the login-logout process.
What I want:
As I understand, I keep adding the InitialViewController to the stack as a modal view, and this is not what I want. I simply want to go back to the start. Or anything that works for that matter. Just as long as I have a simple login/ logout system that works, I'll be glad. Bear in mind that we need to be able to call the View that should be presented from any view in the app if the user appears to be logged out (if he logged out from Facebook, if the Facebook thing timed out, or if the NSUserDefaults for some reason reset (for example under an update)).
If possible, I'd like to know what other apps does to achieve this (for example linkedIn, Facebook, Twitter, or anyone else).
What I've been thinking about is adding a separate LoginView not connected to anything, that I can load up modally whenever I see the user is logged out. Whenever the login is completed, I simply dismiss the view and the user returns to where he was last.
The only problem I see about this is that when the user logs out, he is technically still "inside" the app, though he cannot dismiss the modal view controller without logging in.
Would this be a bearable solution to my problem?
What do you suggest?
Some physical code showing how to present the new view/ going back (or any other solution) is preferred, but any help is appreciated!
I know this was a long question, and there are possibly many answers, but I've been stuck at this for way to long and I just want a solution that will work with my setup. So I felt the need to explain everything. If there's anything you don't get, please don't hesitate to ask!
Thank you so much in advance!

Can Tab Bar view be used only in the second screen application?

I am just starting out iOS development and have some doubts about Tab Bars Human Interface Guidelines provided by Apple.
On the iOS HIG document concerning Tab Bars, it reads:
"A tab bar appears at the bottom edge of the screen and should be
accessible from every location in the app."
The app I am developing and would like to see published in the App Store once finished, would have a ListView as it's first screen that would then go to another screen with a tabbed interface after an item being selected. It would also be possible to go back to the first screen (the one with the list) at any time within the tabbed interface (the 2nd screen).
So, my question is if it's ok to have a Tab Bar interface only in the second screen of an iOS application or would something like that might result in some restrictions by apple approving?
Thanks.
Short answer is YES.
Yes, you can have tab bar in second screen. Consider the app where you have first screen as language select screen and second screen with tab bar controller.
With statement below, what Apple means is once you are in tab-bar controller and tab-bar controller is in scope, tab-bar controller should be accessible. You can hide the tab-bar, but on tapping, it should come again at the bottom of screen.
"A tab bar appears at the bottom edge of the screen and should be accessible from every location in the app."
Main words -> Should be. Apple wants you to make your apps in the most intuitive and user friendly way possible. Many standard apps use this paradigm (ie App Store Application) so they know iOS users are accustomed as to how to navigate. However, Apple themselves even make exceptions to this rule (ie. Playing a song inside the Music App). But yeah, they'll let you do it no problem.

Resources