zoukankan      html  css  js  c++  java
  • 分割器

    分割器目前只支持iPhone6 plus、pad和刚发布的iPhone6s plus。

    建立左右两个view。在根视图中:

     1 #import "AppDelegate.h"
     2 #import "LeftViewController.h"
     3 #import "RightViewController.h"
     4 @interface AppDelegate ()
     5 {
     6     //声明分割器
     7     UISplitViewController *svc;
     8     LeftViewController *viewL;
     9     RightViewController *viewR;
    10     UINavigationController *ncL;
    11     UINavigationController *ncR;
    12 }
    13 @end
    14 
    15 @implementation AppDelegate
    16 
    17 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    18     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    19     // Override point for customization after application launch.
    20     self.window.backgroundColor = [UIColor whiteColor];
    21     [self.window makeKeyAndVisible];
    22     
    23     //创建分割器及两个视图
    24     viewL=[[LeftViewController alloc] init];
    25     ncL=[[UINavigationController alloc] initWithRootViewController:viewL];
    26     viewR=[[RightViewController alloc] init];
    27     ncR=[[UINavigationController alloc] initWithRootViewController:viewR];
    28 
    29     svc=[[UISplitViewController alloc] init];
    30     svc.delegate=self;
    31     //设置分割器分割的视图
    32     svc.viewControllers=@[ncL,ncR];
    33     self.window.rootViewController=svc;
    34 
    35     return YES;
    36 }
    37 #pragma mark - 实现分割器协议函数
    38 -(BOOL)splitViewController:(UISplitViewController *)splitViewController showViewController:(UIViewController *)vc sender:(id)sender{
    39     return NO;
    40 }
    41 -(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation{
    42     return NO;
    43 }


    注意:左边的视图坐标及大小正常取。右边的视图要自适应(判断横屏还是纵屏)

    1     tvR=[[UITableView alloc] init];
    2     //判断横屏还是纵屏
    3     if (self.interfaceOrientation==UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation==UIInterfaceOrientationLandscapeRight) {
    4         //横屏
    5         tvR.frame=CGRectMake(0, 0, 1024-320, 768);
    6     }else{
    7         //纵屏
    8         tvR.frame=CGRectMake(0, 0, 768, 1024);
    9     }
  • 相关阅读:
    5.小程序-生命周期函数
    4.小程序-路由跳转
    3.小程序-事件绑定
    2.小程序-数据绑定
    1.小程序index页静态搭建
    小程序简介
    单链表(Go)
    输入一个字符串,里面有26个英文字母和(半角逗号半角空格半角句号)按照()里的内容进行分割,遇到大写字母把其变成小写,遇到小写的将其变成大写然后输出字符串
    排序算法
    单例模式
  • 原文地址:https://www.cnblogs.com/crushing/p/4820318.html
Copyright © 2011-2022 走看看