您的位置:首页 > 产品设计 > UI/UE

ios UIViewController

2013-11-22 15:09 351 查看
    //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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: