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 ...
随机推荐
- cookie存验证码时间,时间没走完不能再次点击
<script> var balanceSeconds=getcookie('Num'); console.log(balanceSeconds) var timer; var isCli ...
- UVA10410 TreeReconstruction 树重建 (dfs,bfs序的一些性质,以及用栈处理递归 )
题意,给你一颗树的bfs序和dfs序,结点编号小的优先历遍,问你可能的一种树形: 输出每个结点的子结点. 注意到以下事实: (1)dfs序中一个结点的子树结点一定是连续的. (2)bfs,dfs序中的 ...
- appium---命令行启动appium
在客户端的appium长时间运行的时候,出产生一些数据.日志有可能会对appium的内存有所增长,严重的会使appium产生崩溃,这个时候就推荐使用通过cmd进行运行appium, 安装前提需要安装N ...
- C11 C语言文件的读写
目录 文件的打开和关闭 字符流读写文件 文件的打开和关闭 fopen( ) fopen( ) 函数来创建一个新的文件或者打开一个已有的文件,这个调用会初始化类型 FILE 的一个对象,类型 FILE ...
- virtualvenv+django+uWSGI+nginx 部署
原创博文 转载请注明出处! 1. virtualvenv 2. django 3. uWSGI 4. nginx 5. 踩坑记录 1. virtualvenv virtualvenv install ...
- JS数据结构及算法(二) 队列
队列是遵循先进先出的一种数据结构,在尾部添加新元素,并从顶部移除元素. 1.普通队列 function Queue() { this.items = []; } Queue.prototype = { ...
- Linux Ptrace 详解
转 https://blog.csdn.net/u012417380/article/details/60470075 Linux Ptrace 详解 2017年03月05日 18:59:58 阅读数 ...
- selection problem-divide and conquer
思路: 随机选取列表中的一个值v,然后将列表分为小于v的,等于v的,大于v的三组.对于k<=left.size()时, 在left中执行selection:落在中间的,返回v:k>left ...
- poj-2533 longest ordered subsequence(动态规划)
Time limit2000 ms Memory limit65536 kB A numeric sequence of ai is ordered if a1 < a2 < ... &l ...
- HDU - 1251 统计难题(Trie树)
有很多单词(只有小写字母组成,不会有重复的单词出现) 要统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). 每个单词长度不会超过10. Trie树的模板题.这个题内存把控不好容易MLE. ...