zoukankan      html  css  js  c++  java
  • FirstApp,iphone开发学习总结9,旋转

    添加Rotation文件,用类别为UITabBarController添加旋转:

    //Rotation.h文件
    #import <Foundation/Foundation.h>

    @interface UITabBarController(Rotation)
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)x;
    @end

     Rotation.m文件:

    #import "Rotation.h"

    @implementation UITabBarController(Rotation)
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)x {
        return YES;
    }

    @end

    在ButtonViewController.m文件中添加:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)x
    {
        return YES;//此处判定方向,达到要求才旋转
    }

    //此时可以旋转了

    修改right按钮,修改ButtonViewController.h:

    @interface ButtonViewController : UIViewController{
        UIButton *rightBtn;
    }
    @end

     修改ButtonViewController.m文件内的- (void)viewDidLoad:

    - (void)viewDidLoad
    {
        //..
        rightBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];//修改
        //..
        [rightBtn setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];//添加,此处可用 |
        
        //..
    }

     

    不是很具体,这是总结。

    求指点~

  • 相关阅读:
    ViewModel和LiveData问题思考与解答
    vps_centos_7_系统环境常规配置备忘
    JVM内存管理&GC
    sping注解
    ibatis order by 防止sql注入
    好用的绿色工具(mss2sql,jd-gui)
    mysql优化
    Spring事务
    好文分享_java堆栈的区别
    Linux usual cmd
  • 原文地址:https://www.cnblogs.com/maxfong/p/2489582.html
Copyright © 2011-2022 走看看