zoukankan      html  css  js  c++  java
  • UI基础 提示框

    #import "RootViewController.h"
    
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        
        UIButton* button=[UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(10, 100, 120, 60);
        button.backgroundColor=[UIColor redColor];
        [self.view addSubview:button];
        [button addTarget:self action:@selector(touchme) forControlEvents:UIControlEventTouchUpInside];
       
    }
    
    -(void)touchme{
        
        // 提示框(新版)
        UIAlertController* control =[UIAlertController alertControllerWithTitle:@"友情提示" message:@"是否购买" preferredStyle:UIAlertControllerStyleAlert];
        
    //        UIAlertController* control =[UIAlertController alertControllerWithTitle:@"友情提示" message:@"是否购买" preferredStyle:UIAlertControllerStyleActionSheet];
        
        //添加选项
    //    UIAlertAction* act1=[UIAlertAction actionWithTitle:@"买" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    //        NSLog(@"买了");
    //    }];
        
    //    UIAlertAction* act2=[UIAlertAction actionWithTitle:@"不买" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    //        NSLog(@"没钱");
    //    }];
        
        // 红色的那个选项
    //    UIAlertAction* act3=[UIAlertAction actionWithTitle:@"红色" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
    //
    //    }];
        
        
        
        
        //添加选项卡
    //    [control addAction:act1];
    //    [control addAction:act2];
    //    [control addAction:act3];
        
        [self presentViewController:control animated:YES completion:^{
            NSLog(@"弹出来了");
        } ];
        //定时器 repeats Yes 表示间隔 时间运行 No表示只有一次
        [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeOut) userInfo:nil repeats:YES];
        
       
        
    }
    
    
    -(void)timeOut{
        NSLog(@"取消提示框");
        [self dismissViewControllerAnimated:YES completion:^{
            
        }];
    };
    @end
  • 相关阅读:
    Java的快速失败和安全失败
    Java RMI与RPC的区别
    Java动态代理之JDK实现和CGlib实现(简单易懂)
    JVM——字节码增强技术简介
    Linux内存分配机制之伙伴系统和SLAB
    操作系统动态内存管理——malloc和free的工作机制
    Java中的Map
    Java的PriorityQueue
    Java中的List
    Java中的Set
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13341942.html
Copyright © 2011-2022 走看看