ios UIViewController

     //UIViewController 模式跳转
    ViewController *mvc = [[ViewController alloc]init];
    [self.viewController presentViewController:mvc animated:YES completion:^{
        
    }];
    [mvc release];
    
    //关闭模式对话框窗体,跳转回去。
    [self.viewController dismissViewControllerAnimated:YES completion:^{
        
    }];
    //设置跳转方式
    mvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;



#import "ViewController.h"
#import "SubViewController.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.
}


- (void)loadView
{
    [super loadView];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(100, 30, 80, 40);
    [button setTitle:@"open modal" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(openModel) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    self.view.backgroundColor = [UIColor greenColor];
}

- (void)openModel
{
    //模式对话框跳转
    SubViewController *sub = [[SubViewController alloc]init];
    //设置跳转效果
//    sub.modalTransitionStyle = UIModalTransitionStyleCoverVertical;//上下
//    sub.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //左右反转
//    sub.modalTransitionStyle = UIModalTransitionStylePartialCurl; //翻页
    sub.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; //直接跳转
    [self presentViewController:sub animated:YES completion:^{}];
    [sub release];
}
@end



#import "SubViewController.h"

@interface SubViewController ()

@end

@implementation SubViewController


- (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.
}

- (void)loadView
{
    [super loadView];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(100, 30, 80, 40);
    [button setTitle:@"close modal" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(closeModel) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    self.view.backgroundColor = [UIColor redColor];
}

- (void)closeModel
{
    [self dismissViewControllerAnimated:YES completion:^{}];
}
@end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值