IOS6.0 控制器展现方式总结

来源:互联网 发布:miui分屏多任务软件 编辑:程序博客网 时间:2024/06/08 14:52

1. modal a controller
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ControllerA *ca = [storyboard instantiateViewControllerWithIdentifier:@"ControllerA"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:ca];
ca.modalPresentationStyle = UIModalPresentationFullScreen;// 全屏视图显示
ca.modalTransitionStyle = UIModalTransitionStyleCoverVertical;// 从下向上滑出
// modal
[self presentViewController:nav animated:YES completion:NULL];

2. dismiss a modal controller

[self dismissViewControllerAnimated:YES completion:NULL];


3. push a controller

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ControllerA *ca = [storyboard instantiateViewControllerWithIdentifier:@"ControllerA"];
// push
[self.parentViewController.navigationController pushViewController:ca animated:YES];


4. pop a controller

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ControllerA *ca = [storyboard instantiateViewControllerWithIdentifier:@"ControllerA"];

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:ca];
popover.popoverContentSize = CGSizeMake(320, 480);
// pop
[popover presentPopoverFromBarButtonItem:item
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];


5. dismiss a pop controller

[self.popover dismissPopoverAnimated:YES];

0 0