zoukankan      html  css  js  c++  java
  • 设置引导页(第一次登陆进入引导页)

    #import <UIKit/UIKit.h>
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    
    @end
    #import "AppDelegate.h"
    #import "GuideViewController.h"
    #import "RootViewController.h"
    
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
        // 判断是否是第一次登陆
        if (![[NSUserDefaults standardUserDefaults] objectForKey:@"FirstLaunch"]) {
            [[NSUserDefaults standardUserDefaults] setObject:@(true) forKey:@"FirstLaunch"];
            self.window.rootViewController = [[GuideViewController alloc] init];
        }else{
            self.window.rootViewController = [[RootViewController alloc] init];
        }
        
        [self.window makeKeyAndVisible];
        return YES;
    }
    @end
    #import <UIKit/UIKit.h>
    
    @interface GuideViewController : UIViewController
    
    @end
    #import "GuideViewController.h"
    #import "RootViewController.h"
    
    @interface GuideViewController ()
    
    @end
    
    @implementation GuideViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // 初始化scrollView
        UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // 隐藏水平滚动条
        scrollView.showsHorizontalScrollIndicator = NO;
        // 翻页效果
        scrollView.pagingEnabled = YES;
        // 设置scrollView的内容窗口大小
        scrollView.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width * 3, [UIScreen mainScreen].bounds.size.height);
        [self.view addSubview:scrollView];
        // 设置滚动图片
        NSArray *array = [[NSArray alloc] initWithObjects:@"1-1.jpg",@"1-2.jpg",@"1-3.jpg", nil];
        for (int i = 0; i < array.count; i++) {
            UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:array[i]]];
            imageView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width * i, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
            [scrollView addSubview:imageView];
            imageView.tag = 1000 + i;
        }
        // 获取最后一个imageView,然后在其上面加button
        UIImageView *imgView = [self.view viewWithTag:1002];
        // 父视图要可操作,否则其上面的子视图(button)不可操作
        imgView.userInteractionEnabled = YES;
        // 设置button
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        btn.frame = CGRectMake(([UIScreen mainScreen].bounds.size.width - 150)/2.0, [UIScreen mainScreen].bounds.size.height - 120, 150, 80);
        [btn setBackgroundColor:[UIColor clearColor]];
        [btn setTitle:@"马上体验" forState:0];
        [btn setTitleColor:[UIColor redColor] forState:0];
        [btn addTarget:self action:@selector(comeToRootController:) forControlEvents:UIControlEventTouchUpInside];
        [imgView addSubview:btn];
    }
    
    
    
    - (void)comeToRootController:(UIButton *)sender{
        
        RootViewController *root = [[RootViewController alloc] init];
        UIApplication *app = [UIApplication sharedApplication];
        app.keyWindow.rootViewController = root;
    }
    
    @end
    #import <UIKit/UIKit.h>
    
    @interface RootViewController : UIViewController
    
    @end
    #import "RootViewController.h"
    
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor = [UIColor orangeColor];
    }
    
    @end
  • 相关阅读:
    获取最近6个月的年月(yyyyMM,不包括当月)
    checkbox与<c:forEach>在开发中遇到的问题记录
    MyBatis开发-->增删改
    MyBatis开发-->接口方式编程
    MyBatis开发-->入门
    android-async-http框架之与网络进行数据交互
    android-async-http框架之与服务器进行数据交互
    jQuery截取{}里的字符串及获取json里的值
    SSH整合之三:添加Hibernate环境且使之与Spring进行整合
    angular源码剖析之Provider系列--QProvider
  • 原文地址:https://www.cnblogs.com/lantu1989/p/4941043.html
Copyright © 2011-2022 走看看