The launch page is divided into four pages, the last page has a button, click to jump to the home page, four pages of the Home Page

Source: Internet
Author: User

The launch page is divided into four pages, the last page has a button, click to jump to the home page, four pages of the Home Page

 

Code effect: the launch page is divided into four pages, the last page has a button, click to jump to the home page.

 

Code:

 

-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. UIScrollView * sv = [[UIScrollView alloc] initWithFrame: CGRectMake (0, 0,320,460)]; sv. contentSize = CGSizeMake (320*4,460); sv. pagingEnabled = YES; sv. showsHorizontalScrollIndicator = NO; sv. delegate = self; sv. tag = 1; [self. view addSubview: sv]; UIPageControl * pc = [[UIPageControl alloc] initWithFrame: CGRectMake (0,420,320, 20)]; pc. numberOfPages = 4; [pc addTarget: self action: @ selector (pc :) forControlEvents: UIControlEventTouchUpInside]; pc. tag = 2; [self. view addSubview: pc]; for (int I = 0; I <4; I ++) {UIImageView * imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: [NSString stringWithFormat: @ "startcmdd.png", I + 1]; imageView. frame = CGRectMake (320 * I, 0,320,460); [sv addSubview: imageView];} UIButton * button = [UIButton buttonWithType: UIButtonTypeCustom]; button. frame = CGRectMake (320*3 + 100,380,164, 42); [button setImage: [UIImage imageNamed: @ "anniu.png"] forState: UIControlStateNormal]; [button addTarget: self action: @ selector (start) forControlEvents: UIControlEventTouchUpInside]; [sv addSubview: button] ;}# pragma-mark-doClickAction-(void) pc :( UIPageControl *) pc {UIScrollView * sv = (UIScrollView *) [self. view viewWithTag: 1]; sv. contentOffset = CGPointMake (pc. currentPage * 320, 0);}-(void) start {UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "start" message: nil delegate: self cancelButtonTitle: @ "understand" otherButtonTitles: nil, nil]; [alert show];} # pragma-mark-UISCrollerViewDelegate-(void) scrollViewDidScroll :( UIScrollView *) scrollView {UIPageControl * pc = (UIPageControl *) [self. view viewWithTag: 2]; pc. currentPage = scrollView. contentOffset. x/320 ;}

 


Android unit test: the activity to be tested is not started first. It is started only when you click a button on the homepage to jump to the second screen.

You can directly use the code in the onCreate method on the homepage to jump to the page to be tested. Of course, it's temporary code. Remember to delete it.

In android, viewpager is used as an example to describe how an application is used and how to jump to the home page when sliding to the last page.

1. You can add a Button or imageVIew (for example, start) on the Left page. click the button and jump to the home page to use intent (this is currently used by many applications)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.