iOS基础控件-UITabBarController - 3 之<UITabBarControllerDelegate>协议中的四个重要方法
来源:互联网 发布:java string length 编辑:程序博客网 时间:2024/06/06 20:33
让AppDelegate遵守UITabBarControllerDelegate 协议
在XSAppDelegate.m 中的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
方法中
创建UITabBarController 的实例,并将实例的代理设置成AppDelegate
UITabBarController *tabController = [[UITabBarControlleralloc] init];
//将appdelegates实例作为tabController代理
tabController.delegate = self;
tabController.delegate = self;
在XSAppDelegate.m 中 实现协议中的代码
#pragma mark -UITabBarControllerDelegate//是否允许选择不同item触发后续操作,YES 允许,NO不允许
- (BOOL)tabBarController:(UITabBarController*)tabBarController shouldSelectViewController:(UIViewController*)viewController
{
NSLog(@"hello");
return YES;
}
//每次点击tabBarItem后触发这个方法(只有点击标签栏中的五个按钮才会触发,MORE里边的不会触发)
- (void)tabBarController:(UITabBarController*)tabBarController didSelectViewController:(UIViewController*)viewController
{
NSLog(@"%@!",viewController.title);
}
//当点击moreNaviegationController中的编辑按钮时触发的方法
- (void)tabBarController:(UITabBarController*)tabBarController willBeginCustomizingViewControllers:(NSArray*)viewControllers
{
NSLog(@"biaji");
}
//当点击完成按钮的时候,触发此方法
//changed : 标记viewController的顺序是否改变
//ViewControllers返回最新的tabBarController中viewControllers
- (void)tabBarController:(UITabBarController*)tabBarController willEndCustomizingViewControllers:(NSArray*)viewControllers changed:(BOOL)changedNS_AVAILABLE_IOS(3_0)
{
if(changed)
{
NSLog(@"change@");
}
else
{
NSLog(@"not change");
}
for(UIViewController*vc in viewControllers)
{
NSLog(@"%@",vc.title);
}
}
0 0
- iOS基础控件-UITabBarController - 3 之<UITabBarControllerDelegate>协议中的四个重要方法
- [ios]UITabBarController 的UITabBarControllerDelegate 与UITabBarDelegate冲突
- iOS基础控件-UITabBarController-1 初识UITabBarController
- UITabBarController和UITabBarControllerDelegate
- iOS自定义控件 - 自定义UITabBarController中的TabBar
- iOS基础控件-UITabBarController - 2 之UITabBarItem 详解,结合视图控制器和导航控制器的用法
- IOS控件--UITabBarController
- iOS开发基础 - UITabBarController
- iOS中的几个重要方法
- 【iOS自动约束】四个重要的系统方法
- iOS应用之UITabBarController
- iOS开发之UITabBarController
- iOS开发之UITabBarController
- IOS之UITabBarController
- iOS 基础之NSObject中的一些方法
- Intent中的四个重要属性
- iOS-自定义 UITabBarController
- ios基础控件之UITextField常用方法汇总
- 树形结构的数据库表Schema设计
- 画菱形
- SQL执行顺序 经典 例题
- sp dp px之间的区别
- Launcher实现应用列表透明背景
- iOS基础控件-UITabBarController - 3 之<UITabBarControllerDelegate>协议中的四个重要方法
- Linux有名信号量的创建(sem_open中name参数构造)
- 第十周项目2--解密M$pszi$y
- Java EE HTML5 WebSocket 示例
- C++ 中 string 相加拼接的效率问题
- 设计模式学习(结构型模式)—适配器模式(Adapter)
- mac中用命令行运行mysql
- USB基础知识概论
- w3cschool HTML基础三