首页 文章

Tabcontroller问题?

提问于
浏览
0

当我在portait.i中有XIB文件(标签栏控制器)时,如何在横向模式下旋转tabbarcontroller在appdelegate中写下了以下内容

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return YES; },但它不会旋转任何帮助吗?

1 回答

  • 0

    我记得,你不能旋转SDK的UITabBar控制器 . 你chold制作自己的tabbar,从UITabBar继承它,并在shouldAutoRotate方法中返回YES .

    #import <UIKit / UIKit.h>
    @interface MainTabBarController:UITabBarController {
    }

    • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
      @结束

    这是一个.h文件

    #import“MainTabBarController.h”
    @implementation MainTabBarController

    • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      {
      返回YES;
      }
      @结束

    您只需将标签栏的类从UITabBarController更改为MainTabBarController即可

相关问题