1、默认的UITabBarController不支持四个方向,但可以给UITabBarController增加一个类别,实现旋转;具体做法:

在工程添加一个.h和.m文件如下:

//Rotation.h

#import <Foundation/Foundation.h>

@interface UITabBarController(Rotation)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;

@end

 
//Rotation.m

#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支持旋转的更多相关文章

  1. Vue图片浏览组件v-viewer,支持旋转、缩放、翻转等操作

    v-viewer 用于图片浏览的Vue组件,支持旋转.缩放.翻转等操作,基于viewer.js. 从0.x迁移 你需要做的唯一改动就是手动引入样式文件: 1 import 'viewerjs/dist ...

  2. 强大的flash头像上传插件(支持旋转、拖拽、剪裁、生成缩略图等)

    今天介绍的这款flash上传头像功能非常强大,支持php,asp,jsp,asp.net 调用 头像剪裁,预览组件插件. 本组件需要安装Flash Player后才可使用,请从http://dl.pc ...

  3. jquery图片查看插件,支持旋转、放大、缩小、拖拽、缩略图(仿qq图片查看)

    最近做了一个jquery图片查看的插件,目的是能精确查看图片的详情,插件支持图片旋转.放大.缩小.拖拽.缩略图显示,界面效果是按照window的qq查看图片功能写的,当然不尽相同. 具体功能: 1. ...

  4. C#采集UVC摄像头画面并支持旋转和分辨率切换

    在项目中,我们会需要控制uvc摄像头,采集其实时画面,或者对其进行旋转.目前市面上大多数USB摄像头都支持UVC协议.那么如何采集呢?当然是采用SharpCamera!因为SharpCamera支持对 ...

  5. UITabBarController详解

    UITabBarController使用详解 UITabBarController是IOS中很常用的一个viewController,例如系统的闹钟程序,ipod程序等.UITabBarControl ...

  6. UITabBarController 笔记(一)AppDelegate中加UITabBarController 为 rootViewController

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...

  7. UITabBarController使用详解

    UITabBarController是IOS中很常用的一个viewController,例如系统的闹钟程序,ipod 程序等.UITabBarController通常作为整个程序的rootViewCo ...

  8. 学习笔记:UITabBarController使用详解

    一.手动创建UITabBarController 最常见的创建UITabBarController的地方就是在application delegate中的 applicationDidFinishLa ...

  9. iOS开发-UITabBarController详解

    我们在开发中经常会使用到UITabBarController来布局App应用,使用UITabBarController可以使应用看起来更加的清晰,iOS系统的闹钟程序,ipod程序都是非常好的说明和A ...

随机推荐

  1. 51nod 1489 蜥蜴和地下室

    题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 哈利喜欢玩角色扮演的电脑游戏<蜥蜴和地下室>.此时,他正在扮演一个魔术 ...

  2. UOJ #205/BZOJ 4585 【APIO2016】Fireworks 可并堆+凸包优化Dp

    4585: [Apio2016]烟火表演 Time Limit: 40 Sec  Memory Limit: 256 MBSubmit: 115  Solved: 79[Submit][Status] ...

  3. linux+apache+mod_python+wechat_sdk搭建微信公共账号服务器

    linux+apache+mod_python+wechat_sdk搭建微信公共账号服务器 转载请注明本文原作者:FignerLiu PRE 最近尝试了下使用python搭建微信公共账号服务器,实现了 ...

  4. lwz程序人生之启程

    本人14年小本科毕业. 第一次接触电脑是小学4年级.当时,是小学公开课,老师让我们去电脑室秀一下.现在,我都记不得当时我第一次看到电脑室好奇呢?还是没感觉呢? 到初中上电脑课的时候,我才真正了解到电脑 ...

  5. [论文理解]Region-Based Convolutional Networks for Accurate Object Detection and Segmentation

    Region-Based Convolutional Networks for Accurate Object Detection and Segmentation 概括 这是一篇2016年的目标检测 ...

  6. 2018.5.4 AndroidStudio遇到的问题

    新建项目初出现异常报错 Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict 发生这类型的错误, ...

  7. IEDA的安装与破解

    百度搜索IDEA 进入官网下载 https://www.jetbrains.com/idea/download/#section=windows 2.下载好双击即可 3. 完成破解

  8. javaweb基础(3)_tomcat下部署项目

    一.打包JavaWeb应用 在Java中,使用"jar"命令来对将JavaWeb应用打包成一个War包,jar命令的用法如下:

  9. Bootstrap 下拉菜单(dropdown)插件

    使用下拉菜单的插件,您可以向任何组件(比如:导航栏,标签页,胶囊式导航,按钮)添加下拉菜单 用法 您可以切换下拉菜单(dropdown)插件隐藏内容 1.通过data属性,向链接或按钮添加data-t ...

  10. LiteIDE 错误: go build xxxxxx: no non-test Go files in xxxx

    问题 c:/go/bin/go.exe build [C:/Users/Administrator/Desktop/go] go build _/C_/Users/Administrator/Desk ...