Creating a Tutorial for My iOS App with Page Control

Creating a tutorial for my iOS app with page control

Here is a step by step tutorial for what you want to do:
http://www.appcoda.com/uipageviewcontroller-tutorial-intro/

The above tutorial shows how to create a UIPageViewController using Interface Builder. The tutorial was rewritten to make it compatible with iOS 7 and Xcode 5 and to use Storyboard. You can find the updated tutorial at this link: http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/

If you're open to using third party libraries there are several options:

https://github.com/MatthewYork/iPhone-IntroductionTutorial

https://github.com/icepat/ICETutorial

https://github.com/ealeksandrov/EAIntroView

https://github.com/GnosisHub/GHWalkThrough

Create a guide (tutorial) for my ios app

You can implement this yourself by adding the view(s) and controller(s) as usual and add NSUserDefaults to check whether the user is starting the app for the first time or not. If not, you can trigger a segue to your normal Home-ViewController.

Alternatively, you can use one something similar to these:

  • https://github.com/ariok/BWWalkthrough
  • https://github.com/Athlee/OnboardingKit

Presenting walkthrough in iOS app

The best and easiest possible method to show tips would be to use this library:
https://github.com/chrismiles/CMPopTipView

Otherwise, if you want to do it with the approach you mentioned then you will need to keep a variable in NSUserDefaults lets say a bool walkthroughShownOnce. Initially if you are accessing the variable in the app delegate from NSUserDefaults like this:

bool tempInt = [[NSUserDefaults standardUserDefaults] boolForKey:@"walkthroughShownOnce"];

then it will return false. This is when you show your walkthrough and in the end after you have shown the walk through, simply make the variable true like this:

[[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:@"walkthroughShownOnce"];

How I can build 'How to use this app' tutorial inside my iOS app?

Depends on what you want.

You could show a video as @wasted suggests.

Another way of solving this is to use a UIPageViewController which embeds other simple UIViewControllers containing images and text explaining what you app does. An example of how to do that is shown [here] (http://www.appcoda.com/uipageviewcontroller-tutorial-intro/)

You can also find several frameworks made for this purpose, here are some of them:

  • https://github.com/vsouza/awesome-ios
  • https://github.com/ephread/Instructions
  • https://github.com/ariok/BWWalkthrough
  • https://github.com/ruipfcosta/SwiftyWalkthrough

Hope that gives you something to work with.

Which is the preferred way of doing tutorial page with UIPageViewController in swift for first time entering App only

The way I normally do this sort of thing is as follows:

  1. Put the tutorial content in a separate storyboard.
  2. In the initial view controller of the main storyboard, check a
    dedicated variable in the NSUserDefaults to see if user has ever run
    the app before.
  3. If not, then programmatically load up the initial view controller of
    the tutorial storyboard and present it.

This way, the main storyboard isn't loaded up with a bunch of view controllers that are only used once, and there is minimal code to write for the transition.

-- EDIT --

Below is a Swift version of the answer to this question: How can I load storyboard programmatically from class?

let storyboard = UIStoryboard(name: "Tutorial", bundle: nil)
let viewController = storyboard.instantiateInitialViewController()
presentViewController(viewController, animated: true, completion: nil)

How to create a Scroll View with a page control using swift?

import UIKit

class DummyVC: UIViewController, UIScrollViewDelegate {

let scrollView = UIScrollView(frame: CGRect(x:0, y:0, width:320,height: 300))
var colors:[UIColor] = [UIColor.red, UIColor.blue, UIColor.green, UIColor.yellow]
var frame: CGRect = CGRect(x:0, y:0, width:0, height:0)
var pageControl : UIPageControl = UIPageControl(frame: CGRect(x:50,y: 300, width:200, height:50))

override func viewDidLoad() {
super.viewDidLoad()

configurePageControl()

scrollView.delegate = self
scrollView.isPagingEnabled = true

self.view.addSubview(scrollView)
for index in 0..<4 {

frame.origin.x = self.scrollView.frame.size.width * CGFloat(index)
frame.size = self.scrollView.frame.size

let subView = UIView(frame: frame)
subView.backgroundColor = colors[index]
self.scrollView .addSubview(subView)
}

self.scrollView.contentSize = CGSize(width:self.scrollView.frame.size.width * 4,height: self.scrollView.frame.size.height)
pageControl.addTarget(self, action: #selector(self.changePage(sender:)), for: UIControlEvents.valueChanged)

}

func configurePageControl() {
// The total number of pages that are available is based on how many available colors we have.
self.pageControl.numberOfPages = colors.count
self.pageControl.currentPage = 0
self.pageControl.tintColor = UIColor.red
self.pageControl.pageIndicatorTintColor = UIColor.black
self.pageControl.currentPageIndicatorTintColor = UIColor.green
self.view.addSubview(pageControl)

}

// MARK : TO CHANGE WHILE CLICKING ON PAGE CONTROL
func changePage(sender: AnyObject) -> () {
let x = CGFloat(pageControl.currentPage) * scrollView.frame.size.width
scrollView.setContentOffset(CGPoint(x:x, y:0), animated: true)
}

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {

let pageNumber = round(scrollView.contentOffset.x / scrollView.frame.size.width)
pageControl.currentPage = Int(pageNumber)
}

}

How to implement views to the pagecontrol

Here's a simple idea of how to use it.

PageController.h:

#import <UIKit/UIKit.h>

@interface PageController : UIViewController {
NSArray * views;
UIPageControl *pageControl;
}

@property (nonatomic, retain) IBOutlet UIPageControl * pageControl;

- (IBAction) changePage:(id)sender;
- (void) animateToView:(UIView *)newView;

@end

PageController.m:

#import "PageController.h"

@implementation PageController

- (void)viewDidLoad {
[super viewDidLoad];
pageControl.numberOfPages = [views count];
pageControl.currentPage = 0;

// Either wire this up in Interface Builder or do it here.
[pageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
}

- (IBAction) changePage:(id)sender {
UIView * newView = [views objectAtIndex:[pageControl currentPage]];
[self animateToView:newView];
}

- (void) animateToView:(UIView *)newView {
// You'd have to implement this yourself
}

@end


Related Topics



Leave a reply



Submit