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. connect() to 192.168.30.71:8082 failed (99: Cannot assign requested address) while connecting to upstream, client: 114.80.182.136, server: localhost, request: "GET /home/senior HTTP/1.1", upstream: "

    connect() to 192.168.30.71:8082 failed (99: Cannot assign requested address) while connecting to ups ...

  2. NGUI类之间的关系架构

    NGUI Drawcall 1.使用同一个altals的元素尽量放在同一个UIPanel下面,在NGUI中,它消耗的drawcall是以每个Panel为独立计算单位进行计算的. 2.如果一个UIPan ...

  3. Uva 127 poj 1214 `Accordian'' Patience 纸牌游戏 模拟

    Input Input data to the program specifies the order in which cards are dealt from the pack. The inpu ...

  4. 斐讯k2p 月光银 硬件版本A2-软件版本22.7.8.5 刷官改系统

    Mark https://huabuyu.net/斐讯k2p%20月光银%20硬件版本A2-软件版本22.7.8.5%20刷官改系统.html 详细资源推荐:恩山论坛 https://www.righ ...

  5. GIT分布式版本控制器的前后今生

    Git的入门与安装 GIT基础操作 GIT的分支应用 GITLAB应用 gitlab与pycharm应用 GITHUB使用

  6. C语言中math.h中常用的函数

    1.绝对值 ①函数原型: int abs(int x); 函数功能: 求整数x的绝对值 int number=-1234; abs(number); ②函数原型:double fabs(double ...

  7. MySql查询时间段的方法

    本文实例讲述了MySql查询时间段的方法.分享给大家供大家参考.具体方法如下: MySql查询时间段的方法未必人人都会,下面为您介绍两种MySql查询时间段的方法,供大家参考. MySql的时间字段有 ...

  8. java static block

    java 中 静态块的作用 (一)java 静态代码块 静态方法区别一般情况下,如果有些代码必须在项目启动的时候就执行的时候,需要使用静态代码块,这种代码是主动执行的;需要在项目启动的时候就初始化,在 ...

  9. 数组char a[4] 保存了一个数据,怎么转换为unsigned int呢 ?

    [待解决问题] 浏览: 701次 注意char并不表示字符的 a[0]=0; a[1]=0; a[2]=3; a[3]=0; 那么我要的unsigned int b应该等于: b= 0x0000030 ...

  10. CentOS7 中使用 firewall-cmd 控制端口和端口转发

    0X00 firewalld 守护进程 firewall-cmd命令需要firewalld进程处于运行状态.我们可以使用systemctl status/start/stop/restart fire ...