zoukankan      html  css  js  c++  java
  • 添加递进式子视图实例学习

    【基础】
    iPhone编程中心采用两种重要的范型:
    面向对象范型
    模型-视图-控制器(MVC)设计模式

    iPhone上的MVC划分:
    视图        由UIView类以及子类以及其相关的UIViewController类提供。PS:关于此处Controller,个人认知为一个容器,用于保存UIView类的实例,同时负责对屏幕中各项进行布局。

    控制器        通过3中关键技术实现:委托、目标操作和通知
    模型        模型方法拖过数据源和数据含义等协议提供数据,需要实现由控制器触发的回调方法。

    【实例学习】
    在实践Pdf版书中P47的例子中,通过苹果官网资料学习:

    UIView类

    常用属性:
        superview
        subviews
        window
        autoresizingMask UIViewAutoresizing常量,常用UIViewAutoresizingFlexibleWidth and UIViewAutoresizingFlexibleRightMargin
        autoresizesSubviews    标记子视图是否自动重设大小
        tag    标识视图的标签

    常用方法:
        addSubview
        insertSubview
        removeFromSuperview
        viewWithTag    通过标识获取视图指针

    UIViewController类

    为苹果应用程序提供基本的view-management(视图管理)模型。
    UINavigationController,UITabBarController是此类的子类,提供额外行为操作来管理复杂层次关系视图控制器和视图。

    常用属性:
    view:
        当前控制器管理的视图,为控制器当前可见的视图


    常用方法:
    loadView:
        创建视图用于控制器使用。

    willRotateToInterfaceOrientation:
        用于屏幕翻转告知控制器,以响应对应的改变

    shouldAutorotateToInterfaceOrientation:
        返回一个Bool值,来指示当前视图控制器是否支持指定的方向   
        此函数涉及一个常量,如下:
            UIInterfaceOrientation常量:

            typedef enum {
               UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,
               UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
               UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,
               UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft
            } UIInterfaceOrientation;
       
        用于判断用户的屏幕横放和竖放是否支持。比如:看视频,一般都是横起看,那么取值只能UIDeviceOrientationLandscapeRight或UIDeviceOrientationLandscapeLeft。完整代码如下:
        // Allow the view to respond to 2 iPhone Orientation changes,like:
        -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
        {
            return (interfaceOrientation == UIDeviceOrientationLandscapeRight || interfaceOrientation == UIDeviceOrientationLandscapeLeft);
        }
       
    几何类型结构:
    CGRect

        A structure that contains the location and dimensions of a rectangle.

        struct CGRect {
           CGPoint origin;
           CGSize size;
        };
        typedef struct CGRect CGRect;

    CGPoint

        A structure that contains a point in a two-dimensional coordinate system.

        struct CGPoint {
           CGFloat x;
           CGFloat y;
        };
        typedef struct CGPoint CGPoint;

    CGSize

        A structure that contains width and height values.

        struct CGSize {
           CGFloat width;
           CGFloat height;
        };
        typedef struct CGSize CGSize;

    CGFloat

        The basic type for all floating-point values.

        typedef float CGFloat;// 32-bit

        typedef double CGFloat;// 64-bit



    无论生活、还是技术,一切都不断的学习和更新~~~努力~
  • 相关阅读:
    apache 虚拟主机配置(根据不同的域名映射到不同网站)
    Tortoise SVN 使用笔记
    Apache 根据不同的端口 映射不同的站点
    jquery 获取当前元素的索引值
    修改ThinkPHP的验证码类
    NetBeans无法使用编码GBK安全地打开该文件
    在win2003下apache2.2无法加载php5apache2_4.dll
    我看软件工程
    PHP函数参数传递(相对于C++的值传递和引用传递)
    Notepad++ 使用正则表达式查找替换字符串
  • 原文地址:https://www.cnblogs.com/GoGoagg/p/2049072.html
Copyright © 2011-2022 走看看