UITabBarController详解(二)UITabBarController的代理方法以及模态显示
2014-03-15 13:48
393 查看
@首先要实现协议<UITabBarControllerDelegate>
//
设置代理
tabBarController.delegate =self;
//UINavigationController *nav = tabBarController.moreNavigationController;
//[nav setNavigationBarHidden:YES animated:YES];
// 控制哪些ViewController的标签栏能被点击
- (BOOL)tabBarController:(UITabBarController *)tabBarControllershouldSelectViewController:(UIViewController
*)viewController{
//
代表HMT_CViewController这个View无法显示,无法点击到它代表的标签栏
if ([viewControllerisKindOfClass:[HMT_CViewControllerclass]]) {
returnNO;
}
returnYES;
}
//
选中哪个标签栏,一个监控作用吧
- (void)tabBarController:(UITabBarController *)tabBarControllerdidSelectViewController:(UIViewController *)viewController{
}
// More view controller将要开始编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerwillBeginCustomizingViewControllers:(NSArray
*)viewControllers{
}
// More view controller将要结束编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerwillEndCustomizingViewControllers:(NSArray *)viewControllers
changed:(BOOL)changed{
}
// More view controller编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerdidEndCustomizingViewControllers:(NSArray *)viewControllers
changed:(BOOL)changed{
}
#import "HMT-AViewController.h"
#import "HMTModalShowViewController.h"
@interfaceHMT_AViewController ()
@end
@implementation HMT_AViewController
- (void)viewDidLoad
{
[superviewDidLoad];
self.view.backgroundColor = [UIColorredColor];
//
创建一个按钮
UIButton * button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
button.frame =CGRectMake(100,100,100,
100);
[button addTarget:self action:@selector(modalShow)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
// Do any additional setup after loading the view.
}
- (void)modalShow{
HMTModalShowViewController * modalShowVC = [[HMTModalShowViewController alloc]init];
//模态视图控制器呈现出来时候的视觉效果
modalShowVC.modalTransitionStyle =UIModalTransitionStyleCrossDissolve;
/*
UIModalTransitionStyleCoverVertical = 0, //默认,由下往上
UIModalTransitionStyleFlipHorizontal, //水平转动效果
UIModalTransitionStyleCrossDissolve, //渐变效果
UIModalTransitionStylePartialCurl, //书页往上翻动效果
*/
//模态视图控制器呈现方式,默认全屏
modalShowVC.modalPresentationStyle =UIModalPresentationFullScreen;
/*
UIModalPresentationFullScreen = 0,
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext,
UIModalPresentationCustom,
UIModalPresentationNone = -1,
*/
UINavigationController * modalShowNC = [[UINavigationController alloc] initWithRootViewController:modalShowVC];
//推出模态视图控制器
[self presentViewController:modalShowNC animated:YES completion:^{
NSLog(@"hello world");
}];
}
#import "HMTModalShowViewController.h"
@interfaceHMTModalShowViewController ()
@end
@implementation HMTModalShowViewController
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor yellowColor];
//
利用UINavigationController来实现退出控制器
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(modalDismiss)];
self.navigationItem.leftBarButtonItem = barButton;
self.navigationItem.title =@"humingtao";
//创建一个按钮来实现退出控制器
/* UIButton * button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
button.frame = CGRectMake(100, 100, 100, 100);
[button addTarget:self action:@selector(modalDismiss) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];*/
}
- (void)modalDismiss{
//退出模态视图控制器
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"退出GoodBye");
}];
}
@end
//
设置代理
tabBarController.delegate =self;
//UINavigationController *nav = tabBarController.moreNavigationController;
//[nav setNavigationBarHidden:YES animated:YES];
// 控制哪些ViewController的标签栏能被点击
- (BOOL)tabBarController:(UITabBarController *)tabBarControllershouldSelectViewController:(UIViewController
*)viewController{
//
代表HMT_CViewController这个View无法显示,无法点击到它代表的标签栏
if ([viewControllerisKindOfClass:[HMT_CViewControllerclass]]) {
returnNO;
}
returnYES;
}
//
选中哪个标签栏,一个监控作用吧
- (void)tabBarController:(UITabBarController *)tabBarControllerdidSelectViewController:(UIViewController *)viewController{
}
// More view controller将要开始编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerwillBeginCustomizingViewControllers:(NSArray
*)viewControllers{
}
// More view controller将要结束编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerwillEndCustomizingViewControllers:(NSArray *)viewControllers
changed:(BOOL)changed{
}
// More view controller编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerdidEndCustomizingViewControllers:(NSArray *)viewControllers
changed:(BOOL)changed{
}
#import "HMT-AViewController.h"
#import "HMTModalShowViewController.h"
@interfaceHMT_AViewController ()
@end
@implementation HMT_AViewController
- (void)viewDidLoad
{
[superviewDidLoad];
self.view.backgroundColor = [UIColorredColor];
//
创建一个按钮
UIButton * button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
button.frame =CGRectMake(100,100,100,
100);
[button addTarget:self action:@selector(modalShow)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
// Do any additional setup after loading the view.
}
- (void)modalShow{
HMTModalShowViewController * modalShowVC = [[HMTModalShowViewController alloc]init];
//模态视图控制器呈现出来时候的视觉效果
modalShowVC.modalTransitionStyle =UIModalTransitionStyleCrossDissolve;
/*
UIModalTransitionStyleCoverVertical = 0, //默认,由下往上
UIModalTransitionStyleFlipHorizontal, //水平转动效果
UIModalTransitionStyleCrossDissolve, //渐变效果
UIModalTransitionStylePartialCurl, //书页往上翻动效果
*/
//模态视图控制器呈现方式,默认全屏
modalShowVC.modalPresentationStyle =UIModalPresentationFullScreen;
/*
UIModalPresentationFullScreen = 0,
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext,
UIModalPresentationCustom,
UIModalPresentationNone = -1,
*/
UINavigationController * modalShowNC = [[UINavigationController alloc] initWithRootViewController:modalShowVC];
//推出模态视图控制器
[self presentViewController:modalShowNC animated:YES completion:^{
NSLog(@"hello world");
}];
}
#import "HMTModalShowViewController.h"
@interfaceHMTModalShowViewController ()
@end
@implementation HMTModalShowViewController
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor yellowColor];
//
利用UINavigationController来实现退出控制器
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(modalDismiss)];
self.navigationItem.leftBarButtonItem = barButton;
self.navigationItem.title =@"humingtao";
//创建一个按钮来实现退出控制器
/* UIButton * button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
button.frame = CGRectMake(100, 100, 100, 100);
[button addTarget:self action:@selector(modalDismiss) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];*/
}
- (void)modalDismiss{
//退出模态视图控制器
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"退出GoodBye");
}];
}
@end
相关文章推荐
- 【iOS开发-30】UITabBarController的几种代理方法以及结合NSUserDefaults还原上次退出时被选中视图控制器和视图控制器的顺序
- 【iOS开发-30】UITabBarController的几种代理方法以及结合NSUserDefaults还原上次退出时被选中视图控制器和视图控制器的顺序
- iOS开发UITabBarController的几种代理方法以及结合NSUserDefaults还原上次退出时被选中视图控制器和视图控制器的顺序
- Asp.net中图片存储数据库以及页面读取显示通用方法详解
- Asp.net中图片存储数据库以及页面读取显示通用方法详解
- Asp.net中图片存储数据库以及页面读取显示通用方法详解-附源码下载
- Asp.net中图片存储数据库以及页面读取显示通用方法详解-附源码下载
- Asp.net 中图片存储数据库以及页面读取显示通用方法详解-附源码下载
- Asp.net中图片存储数据库以及页面读取显示通用方法详解
- 系统UITabBarController的tabBar隐藏时显示白条的解决方法
- spr 4000 ingmvc 属性放数据库中解决方法 以及 @Controller 中 使用@vlaue无法注入属性值问题详解
- ios更改UITabBarController背景以及选中背景图片的方法
- 用UICollectionView及其controller相关UICollectionViewDataSource,UICollectionViewDelegate代理实现多列显示方法
- ios更改UITabBarController背景以及选中背景图片的方法 以及隐藏tabbar
- Asp.net 中图片存储数据库以及页面读取显示通用方法详解
- UITabBarController+UINavigationController 进入应用只显示一个tab的解决方法
- UISearchDisplayController(iOS < 8.0)实例应用实现搜索功能和VC展示效果, 以及代理方法的介绍
- ios更改UITabBarController背景以及选中背景图片的方法
- ios更改UITabBarController背景以及选中背景图片的方法
- PowerDesigner16.5快速入门显示,注释comment配置方法,以及创建sql文件过程中需要注意的一些问题