Only the first time you enter the navigation view and the first navigation View

Source: Internet
Author: User

Only the first time you enter the navigation view and the first navigation View

Only when the program is run for the first time can the program be deleted and re-run.

I only show the last image.

 

First create a viewcontroller class

Set the Root View in APPDelegate.

Then

Write in UseGuideViewController. h

FirstViewController is my main interface.

Macro definition width and height

#import <UIKit/UIKit.h>#import "FirstViewController.h"#define WIDTH  self.view.frame.size.width#define HEIGHT self.view.frame.size.height@interface UseGuideViewController : UIViewController<UIScrollViewDelegate>@end

The following is the code in UseGuideViewController. m, which has some comments.

 

# Import "UseGuideViewController. h "@ interface UseGuideViewController () @ end @ implementation UseGuideViewController-(void) viewDidLoad {[super viewDidLoad]; [self initGuide];}-(void) didreceivemorywarning {[super busy]; // Dispose of any resources that can be recreated .} -(void) initGuide {UIScrollView * scrollView = [[UIScrollView alloc] initWithFrame: CGRectMake (0, 0, WIDTH, HEIGHT)]; [scrollView setContentSize: CGSizeMake (WIDTH * 4, 0)]; [scrollView setPagingEnabled: YES]; // View display on the entire page // [scrollView setBounces: NO]; // avoid the bounce effect and expose the Root View to scrollView. delegate = self; UIImageView * imageview = [[UIImageView alloc] initWithFrame: CGRectMake (0, 0, WIDTH, HEIGHT)]; [imageview setImage: [UIImage imageNamed: @ "5.png"]; [scrollView addSubview: imageview]; UIImageView * imageview1 = [[UIImageView alloc] initWithFrame: CGRectMake (WIDTH, 0, WIDTH, HEIGHT)]; [imageview1 setImage: [UIImage imageNamed: @ "004.png"]; [scrollView addSubview: imageview1]; UIImageView * imageview2 = [[UIImageView alloc] initWithFrame: CGRectMake (WIDTH * 2, 0, WIDTH, HEIGHT)]; [imageview2 setImage: [UIImage imageNamed: @ "006.png"]; [scrollView addSubview: imageview2]; UIImageView * imageview3 = [[UIImageView alloc] initWithFrame: CGRectMake (WIDTH * 3, 0, WIDTH, HEIGHT)]; [imageview3 setImage: [UIImage imageNamed: @ "0.png"]; imageview3.userInteractionEnabled = YES; // enable user interaction of imageview3; otherwise, the following button cannot respond to [scrollView addSubview: imageview3]; UIButton * button = [UIButton buttonWithType: UIButtonTypeCustom]; // load a transparent button [button setTitle: nil forState: UIControlStateNormal]; [button setFrame: CGRectMake (250, 20,150, 40)]; [button addTarget: self action: @ selector (firstpressed) forControlEvents: UIControlEventTouchUpInside]; [button setTitle: @ "go to the main interface" forState: 0]; [button setTitleColor: [UIColor colorWithRed: 0.305 green: 1.000 blue: 0.901 alpha: 1.000] forState: 0]; [imageview3 addSubview: button]; [self. view addSubview: scrollView];}-(void) firstpressed {FirstViewController * firstvc = [FirstViewController new]; [self presentViewController: firstvc animated: YES completion: ^ {NSLog (@ "the page has been switched. modal View ") ;}] ;}/ * # pragma mark-Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation-(void) prepareForSegue :( UIStoryboardSegue *) segue sender :( id) sender {// Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller .} * // @ end

Well, this is my brief introduction. Maybe not mature, but I am working hard for it.

Related Article

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.