Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intro at the beginning of the app [closed]

Tags:

xcode

ios

On some apps, they have a little intro, that you can slide through different view controllers, that talk about it. For example: Evernote, etc. What's the name of this? And any good tutorial on how to do it?

like image 345
foxcowz Avatar asked Apr 17 '15 03:04

foxcowz


2 Answers

No,There is no any ready made controller not available for introduction.You need to implement UIScrollView and create your custom view and put into that scrollview.

Following is the list of the different github demo projects for intro screen.

  1. Surfboard
  2. EAIntroView
  3. iPhone-IntroductionTutorial
  4. GHWalkThrough
  5. AOTutorial
  6. MYBlurIntroductionView
  7. ICETutorial
  8. ABCIntroView
  9. EKWelcomeView

May this help lot,

Happy coding.

like image 151
Nimit Parekh Avatar answered Nov 15 '22 21:11

Nimit Parekh


You can also use UIPageViewController.

1. Create an instance of UIPageViewController

    self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll 
                                                              navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal 
                                                                            options:nil];
    self.pageViewController.frame = self.view.bounds;

2. Implement its UIPageViewControllerDataSource protocol

    self.pageViewController.dataSource = self;
    ....
    - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController 
          viewControllerBeforeViewController:(UIViewController *)viewController 
    {

       NSUInteger index = [(PageContentViewController *)viewController pageIndex]; // get any kind of index of the view controller to know its position
        // here I subclass UIViewController to hold the index

        if (index == 0) {
            return nil;
        }  

       // get the previous view controller
       return self.pages[--index]; // container of all your pages
    }


    - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
         // do the same as above but get the next view controller or nil if index >= [self.pages count]
     }

     - (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
        // how many items do we have
        return [self.pages count];
     }

     - (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
        // The selected item reflected in the page indicator.
        return 0;
     }

3. Create your pages.

     self.pages = [[NSMutableArray alloc] init];
     for (NSUInteger i=0; i<10; i++) { // 10 pages
         PageContentViewController *page = [self.storyboard instantiateViewControllerWithIdentifier:@"PageContentViewController1"]; // you can also do it programmatically
         // subclass of UIViewController just to hold its page index and for unified style purpose
         page.pageIndex = i;
         [self.pages addObject:page];
     }

4. Display pages

     NSArray *viewControllers = [NSArray arrayWithObject:self.pages[0]];
     [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

     [self addChildViewController:self.pageViewController];
     [self.view addSubview:self.pageViewController.view];
     [self.pageViewController didMoveToParentViewController:self];

5. Dismiss

     [self.pageViewController.view removeFromSuperview];
     [self.pageViewController removeFromParentViewController];

Want to add some fancy animations when page view controller is shown?

     CATransition *transition = [CATransition animation];
     transition.duration = 0.4;
     transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
     transition.type = kCATransitionPush;
     transition.subtype = kCATransitionFromTop;
     [self.pageViewController.view.layer addAnimation:transition forKey:kCATransition];
like image 4
Duc Avatar answered Nov 15 '22 21:11

Duc