应用程序开头介绍

时间:2015-04-17 03:53:46

标签: ios xcode

在某些应用上,它们有一些介绍,您可以通过不同的视图控制器进行滑动,然后再谈论它。例如:Evernote等。这是什么名字?还有关于如何做到这一点的好教程?

2 个答案:

答案 0 :(得分:14)

不,没有任何现成的控制器无法进行介绍。您需要实施UIScrollView并创建自定义视图并将其放入scrollview

以下是介绍屏幕的不同github演示项目列表。

  1. Surfboard
  2. EAIntroView
  3. iPhone-IntroductionTutorial
  4. GHWalkThrough
  5. AOTutorial
  6. MYBlurIntroductionView
  7. ICETutorial
  8. ABCIntroView
  9. EKWelcomeView
  10. 愿这个有用了,

    快乐的编码。

答案 1 :(得分:4)

您也可以使用UIPageViewController。

<强> 1。创建UIPageViewController的实例

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

<强> 2。实现其UIPageViewControllerDataSource协议

    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。创建您的网页。

     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。显示页面

     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。驳回

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

想要在显示页面视图控制器时添加一些精美的动画吗?

     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];