zoukankan      html  css  js  c++  java
  • iOS.iPad.03.UIModal

    1、案例介绍:iPad上使用多种风格的ModalView,如图01,02,03,04,05

    图01图02

    图03图04

    图05

    2、代码

    ViewController.h

    #import <UIKit/UIKit.h>
    
    @interface ViewController : UIViewController
    
    - (IBAction)onclick:(id)sender;
    
    @property (weak, nonatomic) IBOutlet UISegmentedControl *segControl;
    
    @end

    ViewController.m

    #import "ViewController.h"
    #import "ModalViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    - (IBAction)onclick:(id)sender {
        
        ModalViewController *modalViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"modalViewController"];
        
        modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        
        switch (self.segControl.selectedSegmentIndex) {
            case 0:
                modalViewController.modalPresentationStyle = UIModalPresentationFullScreen;
                break;
            case 1:
                modalViewController.modalPresentationStyle = UIModalPresentationPageSheet;
                break;
            case 2:
                modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;
                break;
            default:
                modalViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
                break;
        }
        
        [self presentViewController:modalViewController animated:YES completion:nil];
        
        
    }
    @end

    ModalViewController.h

    #import <UIKit/UIKit.h>
    
    @interface ModalViewController : UIViewController
    
    - (IBAction)onclick:(id)sender;
    
    @end

    ModalViewController.m

    #import "ModalViewController.h"
    
    @interface ModalViewController ()
    
    @end
    
    @implementation ModalViewController
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    - (IBAction)onclick:(id)sender {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    @end

    3、故事版

  • 相关阅读:
    Construct Binary Tree from Preorder and Inorder Traversal
    Construct Binary Tree from Inorder and Postorder Traversal
    Maximum Depth of Binary Tree
    Sharepoint 2013 创建TimeJob 自动发送邮件
    IE8 不能够在Sharepoint平台上在线打开Office文档解决方案
    TFS安装与管理
    局域网通过IP查看对方计算机名,通过计算机名查看对方IP以及查看在线所有电脑IP
    JS 隐藏Sharepoint中List Item View页面的某一个字段
    SharePoint Calculated Column Formulas & Functions
    JS 两个一组数组转二维数组
  • 原文地址:https://www.cnblogs.com/cqchen/p/3773918.html
Copyright © 2011-2022 走看看