UITabBarController支持旋转
1、默认的UITabBarController不支持四个方向,但可以给UITabBarController增加一个类别,实现旋转;具体做法:
在工程添加一个.h和.m文件如下:
//Rotation.h
#import <Foundation/Foundation.h>
@interface UITabBarController(Rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end
#import "Rotation.h"
@implementation UITabBarController(Rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
@end
重新编译,运行后UITabBarController就可以支持四个方向了;
2、进一步,如果UITabBarController包含多个ViewController,如A,B,C三个;但我们只想A,B,支持四个方向,而C只支持一个方向,则在
//Rotation.m
#import "Rotation.h"
@implementation UITabBarController(Rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if([[self selectedViewController] isKindOfClass:[C class]]){
return NO;
}
return YES;
}
@end
3、隐藏底边的UITabBar
(1)假如你在某一个ViewController中隐藏UITabBar,则可以在该控制器中添加下面的函数
- (void)viewDidAppear:(BOOL)animated{
self.hidesBottomBarWhenPushed = YES;
}
(2)为了将某个视图全屏显示,而隐藏UITabBar,添加下面的函数
- (void)HideTabBar:(BOOL)hidden{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0];
for(UIView *view in self.tabBarController.view.subviews){
if([view isKindOfClass:[UITabBar class]]){ //处理UITabBar视图
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width,view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, 480-48, view.frame.size.width,view.frame.size.height)];
}
}else{ //处理其它视图
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x,view.frame.origin.y,
view.frame.size.width,480)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,view.frame.size.width,480-48)];
}
}
}
[UIView commitAnimations];
}
UITabBarController支持旋转的更多相关文章
- Vue图片浏览组件v-viewer,支持旋转、缩放、翻转等操作
v-viewer 用于图片浏览的Vue组件,支持旋转.缩放.翻转等操作,基于viewer.js. 从0.x迁移 你需要做的唯一改动就是手动引入样式文件: 1 import 'viewerjs/dist ...
- 强大的flash头像上传插件(支持旋转、拖拽、剪裁、生成缩略图等)
今天介绍的这款flash上传头像功能非常强大,支持php,asp,jsp,asp.net 调用 头像剪裁,预览组件插件. 本组件需要安装Flash Player后才可使用,请从http://dl.pc ...
- jquery图片查看插件,支持旋转、放大、缩小、拖拽、缩略图(仿qq图片查看)
最近做了一个jquery图片查看的插件,目的是能精确查看图片的详情,插件支持图片旋转.放大.缩小.拖拽.缩略图显示,界面效果是按照window的qq查看图片功能写的,当然不尽相同. 具体功能: 1. ...
- C#采集UVC摄像头画面并支持旋转和分辨率切换
在项目中,我们会需要控制uvc摄像头,采集其实时画面,或者对其进行旋转.目前市面上大多数USB摄像头都支持UVC协议.那么如何采集呢?当然是采用SharpCamera!因为SharpCamera支持对 ...
- UITabBarController详解
UITabBarController使用详解 UITabBarController是IOS中很常用的一个viewController,例如系统的闹钟程序,ipod程序等.UITabBarControl ...
- UITabBarController 笔记(一)AppDelegate中加UITabBarController 为 rootViewController
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...
- UITabBarController使用详解
UITabBarController是IOS中很常用的一个viewController,例如系统的闹钟程序,ipod 程序等.UITabBarController通常作为整个程序的rootViewCo ...
- 学习笔记:UITabBarController使用详解
一.手动创建UITabBarController 最常见的创建UITabBarController的地方就是在application delegate中的 applicationDidFinishLa ...
- iOS开发-UITabBarController详解
我们在开发中经常会使用到UITabBarController来布局App应用,使用UITabBarController可以使应用看起来更加的清晰,iOS系统的闹钟程序,ipod程序都是非常好的说明和A ...
随机推荐
- 卓越管理的实践技巧(4)如何才能给予有效的反馈 Guide to Giving Effective Feedback
Guide to Giving Effective Feedback 前文卓越管理的秘密(Behind Closed Doors)最后一部分提到了总结的13条卓越管理的实践技巧并列出了所有实践技巧名称 ...
- cv2.solvepnp 相机的位姿估计
预备知识 图像坐标系: 理想的图像坐标系原点O1和真实的O0有一定的偏差,由此我们建立了等式(1)和(2),可以用矩阵形式(3)表示. 相机坐标系(C)和世界坐标系(W): 通过相机与图像的投 ...
- Spring归纳
Spring总结 bean标签的scope属性 scope="singleton",单例模式,默认值 scope="prototype",多例模式 注解元素 @ ...
- Python01 VSCode开发环境和入门程序
1.Python的下载和安装 最新版本python3.7.3 https://www.python.org/downloads/release/python-373/ web-based: 在线安装包 ...
- sqlite 新建实体时出错
解决方式 手动下载 问题原因
- Bootstrap历练实例:标签页内的下拉菜单
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- HTML5<aside>元素
HTML5<aside>元素用来定义页面文档中主区域内容之外的内容,但之外的内容是与主区域内容相关的. 实例: <article> <h1>这个页面是我开始用htm ...
- Sql Server 查询今天,昨天,近七天....数据
今天数据: 昨天数据: 7天内数据: 30天内数据: 本月数据: 本年数据: 查询今天是今年的第几天: select datepart(dayofyear,getDate()) 查询今天是本月的第几天 ...
- 如何解决U盘装系统后磁盘总容量变小?
我在用Win32_Disk_Imager工具制作U盘系统盘之后,发现U盘大小变为2M,另外的大小没有被分配,解决办法如下. 打开:http://jingyan.baidu.com/article/59 ...
- 洛谷 4219/BZOJ 4530 大融合
4530: [Bjoi2014]大融合 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 990 Solved: 604[Submit][Status] ...