Walkthrough with tab view controller - ios

I have been attempting to create a walkthrough for my app although I also have a tab view controller which is the initial view controller. I have been able to identify when a user is opening the app for the first time, but when I make the walkthrough view controller initial, I get a Sigbart error. This is because I set up my tabbar in the app delegate.
Is there a way to possibly keep the tab bar VC the initial and hide the first VC if it is the users first time opening the app?
Is there another way of doing it?

I dont know the code to check of its the flrst time a user opens an app, but why dont you make that check on your tab bar controller? And then lf lt ls the first time, you just change the root vc to the tutorial vc. When they are done with the tutorial you just change back the root vc to the tab bar.

There easiest way to accomplish the tutorial-like behavior for new users is:
1) Make a new View Controller be the initial one.
2) Add code to check if its the first time the user launched the app. If it is, show the tutorial, if its not, show your tab view controller.
3) You can fill this "fake initial" view controller with the same image shown in the splash screen. This way the user will feel its just the splash one.
*) An added benefit of this approach is that you can check other useful things. For example, if your app has some kind of login feature you can manage it here skipping the login window for users who have already logged in. It can also be used to update your app's resources in case you are retrieving them from a server.

Related

how to avoid circular segues in swift

I have a project which has the following structure:
The user is presented with a login view controller, on successful login, a tab group is opened. One of the tabs is a profile tab. From within there, a user can click on a following or followers button.
Each of these buttons segue onto a list of users. From there each user is clickable and this leads onto a 'membersDetailed' controller. Within that controller, there is again a followers and following button. This again is clickable and leads to a list of users who are then clickable leading back to 'membersDetailed' again. So with the current set up, the user can keep going further and further in and memory is a concern for me.
How can I handle this is the most memory efficient way? Should I be programmatically popping controllers instead of using storyboard segues or what is the best approach?
I'm also noticing that when I navigate back along the chain the memory doesn't seem to reduce. Even though I am using a navigation controller.
Any help appreciated.
You can use Unwind Segue to go back or on the reverse direction

iOS (ipad) split view controller

I have a couple views that come before I want to show my split view, disclaimer and then login. After successful login I want to segue to the the split view controller. However I do not think there is a way in storyboards to segue to a split view controller. How do I get from a normal view into my split view controller.
Sometimes if it seems to cumbersome it may be an indication that one need to look at the problem from a different angle.
Assuming your goal is that of forcing the user to go through the login process,
this is what I would do:
Have your splitView as the default view controller, added in the storyboard and loaded as the app starts
As soon as app is loaded, check for the existence of the user's credential. If you don't find any,
present your login framework modally (full screen to cover any data underneath).
Once the user has successfully logged it, dismiss the modalVC and you will have the underlying splitVC underneath ready for use.

Segue type to be used for a user registration process - iOS 5

This is my first ios app & I have a user registration process which is separated out into 3 screens. The first screen has user to enter his mobile number, the second screen asks him select his location & the third screen asks him to enter his birthday and a few other details.
So in total, there are totally 3 controllers which I have used.
1) mobile_number_controller.rb
2) location_controller.rb
3) miscellaneous_details_controller.rb
Each detail the user enters is validated and is stored into the NSUserDefaults. If the validation fails then the user is not allowed to move to the next screen. Also, once the user enters his details correctly, then the user does not have a back button to go back to the previous screen as well.
I would like to know which is the type of segue to be used here. Should I embed these controllers in a navigation controller and use a push segue, or should I be using a modal segue?
Update regarding the chain of controllers.
I don't intend to take the user back to any presenting controller at any stage. Also, in most code I have read till now, for modal segues, I have seen the presented controller being dismissed or there's an unwind segue to go back to the presented controller. I am a bit confused on what to do with these presented controller here before presenting the next controller in the series?
Also, as I mentioned that I store whatever data has been entered by the user in NSUserDefaults, theres no need for the presenting controller to know about the data entered in the presented controller. Hence I don't feel the need for an unwind segue( like in the 'new contacts' application).
Any help on this would be much appreciated.
I would prefer a modal segue to present a navigation controller and push segues to connect the other view controllers. Similar to webapps a user perhaps want to step back to change previously entered information.
I would use a series of modal segues (presented view controller). This is not a "user can go forward and back among views" situation: you are in total control of what the user sees. It is perfectly legal to present a view controller on top of a presented view controller. Moreover, it is simple to control how far back you take the user, e.g. go back all the way (dismissing all the views), if that's what you want to do.

iOS complex navigation between view controllers

I have a complex flow between view controllers (vc). When my main view controller shows, it checks if a user is logged in, and if not, it pushes a log in vc in viewWillAppear. The login then can the push a register vc. Further, on app's very first start, it also shows a special vc, also from the main vc's viewWillAppear (just once). It does not matter if the user has logged in or skipped the log in.
The app can be opened also by custom URLs, which should open one of my vcs. The app must start/resume at that screen without any visble transition between vcs. All this flow is handled from my main vc, which handles this in viewWillAppear and in didBecomeActive which is an observer for app's UIApplicationDidBecomeActiveNotification. Some of those custom URLs must open the login screen first.
My naive approach was to handle all this logic in my main vc's viewWillAppear where I pushed vcs base on the current state. This works for pushing the login screen on app's start without any problem. The problem is that when I return from the login and I need to push another vc. The main navigation controller knows that something was pushed (the back button becomes visible) but the old vc is visible (the main), with partially broken views, and does not react to touch events. Tapping the back button makes a complete mess from my app.
I googled and the problem seems to be that we cannot push a vc while another one is popping. I have found a BufferedNavigationController, which solves this, but it does not work correctly under iOS7 yet. I do not even see any logs in device's console.
Another issues is that while the app is in the background a memory warning could mess my vc's and the app has completely different startup than a normal resume from the background.
At the moment I came with a quick hack where I create a custom backstack for all the situations and set it as the navigation controller's back stack and push the last vc on top of that stack. Then in the login/register screens I modify the backstack if a user skipped the login/register process. This is an ugly hack an not a very future proof solution. I would like to centrally controll the pushing of vcs in one place and there cannot be any visible transition between them in that situation.
Is there any better/more robust solution to achieve this? I cannot have visible transition when returning back from one vc (this is animated) and the vc beneath it should push another on top of it while it becomes visible (no animation of this push). So it looks like we return to a completely different screen? No matter if it can be confusing for users, that is for another question.
EDIT 1: I am targeting iOS7 and newer only.
EDIT 2: Here is a sample demo which shows my issue. I directed the link to he main vc, which pushes other vcs in its viewWillAppear (the other vcs are not important). It is just for presentaion purposes.
This demo shows logs into console "nested push animation can result in corrupted navigation bar" and "Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted." which do not show up in my big project. I know what they mean, but how can I push a vc when antoher is popping away? The mentioned BufferedNavigationController does not work for me on iOS 7 (and it is not a problem, that it does not use ARC).
EDIT 3: When I start the provided demo for the first time, it will open the login screen instead of the main - good. Then after tapping the login it goes back to the main screen and should instantly push the another screen without the main being visible. It does not do that, the main is visible but the navbar thinks there is something above the main, thus the visible back button. It corrupts the backstack...
https://stackoverflow.com/a/20947860/1405008
Refer this for your first scenario like open login or other view controller.
For custom URL u can also use the same logic and check and present when its arrive from custom URL.
Always set the root view Controller will the easiest way to do this kind of different navigation stuffs in Your application also this approach avoid unwanted view-controller in stack.

iOS views navigation best practices

I'm very new in iOS dev (but have more then 10 years overall experience with other platforms so it should help). Now I have to create relatively complex iOS application and do it very fast :).
I created application based on 'Tabbed Application' template using storyboard. Then I added login view that uses JSON to communicate with web application. I made this view initial (first that user sees) by moving appropriate arrow from default tab bar controller to my 'login view controller'.
On the login view I have text fields and login button. By clicking button application verifies user's name and password and then navigate him to default tab bar controller (created by Xcode). I do it with this code:
WPFirstViewController *fvc = [self.storyboard instantiateViewControllerWithIdentifier: #"TabBars"];
[fvc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:fvc animated:YES completion:nil];
Everything works fine, but I'm confused than I didn't use graphics lines between views on storyboard and I'm not sure that my approach is correct.
So, questions is how should I navigate user from the login view to tab bar controller? What is the best way in my case? And also, how for example should I navigate user from one of the tab view controller pages page (for example, by clicking button 'Settings') to corresponding view and then back? Maybe somebody could share a link to some good article.
Sorry for the long text. Thank you in advance for your help!
Modal view controllers are supposed to be used for cases where you need to get some critical information from the user (or present some to the user), without which you can't continue with the app. A log in controller would be a good choice for a modal view controller, but your main controller, your tab bar controller isn't. It would be better to present the login controller modally from the controller in the first tab of your tab bar controller. If you do this from viewDidAppear, and with no animation, it will be the first thing the user sees. When the user successfully logs in, just dismiss that controller, and you'll be ready to go in your first tab.
I'm not sure what you mean by your second question. The user navigates between the tabs by clicking on a tab -- you don't need to do anything in code for that.
I would advise you not to use storyBoards. Also, if you are planning to have a navigation controller on your app, then you will definitely use the feature of pushing view controllers on a self.navigationViewController of your view controller. It's easy to use, really easy!!
Typically, login view controllers should be modally presented with: presentModalViewController:animated:
In regards to your UITabBarController, each tab can be a UINavigationController, which will enable you to maintain a stack of UIViewControllers.
All the remains is determining whether the view controller you want to present is modal, or part of said stack.

Resources