zoukankan      html  css  js  c++  java
  • objective c

    为什么要有属性呢

    1 是为了实例变量的安全性和再分类性, 保障安全

    2 提供一个阀门,延迟实例化。列新BUI

    记下哪些对象需要重 绘 一致性检查

    本身是很有价值的

    实例变量

    必需要有实例变量来支持属性吗?

    不含属性的实例变量

    .好读

    .和结构体有关系

    strong VS weak

    是我们给指针的描述或属性

    非强即弱

    strong 是对于对象来说的

    指针的强弱是用于表示指向对象的指针。而用于指向存储器的指针

    强指针是指通过指针被保存在堆中,而不把它分配到存储器,直到我不再用强指针把指针设为零,把我从堆里弄出来,

    weak  不重要的,,,

    弱指针只在ios5中应用程序运行时起作用

    从堆中出来时,,归零

    dealloc

    当在本地变量超 出他的scope后,就不再指 向了。

    编译器给你做引用计数,一人

     UIInterfaceOrientationIsPortrait

    UIInterfaceOrientationPortraitUpsideDown

    landscape left    landscape right

    也可以禁止某个方向
    Autorotation

    You can control whether the user interface rotates along with it

    Implement the following method in your computer

    - (BOOL) shouldAutorotationToInterfaceOrientation::(UIInterfaceOrientation)orientation

    {

      return UIInterfaceOrientationIsPortrait(orientation);

      return YES;

      return (orientation != UIINterfaceOrientationPortraitUpSideDown);

    }

    if you support an orientation, what will happen when rotatd?

    the frame of all subviews in your controllers view will be adjested.

    the adjustment i baseed on ther struts and springs

    you set strut and sprintg in xcode

    when a view's bounds changes because it frams is altered does drwaRect, get called again???no

    你的视图会改变自己的边界再次变得宽而短 或长而窄

    各子视图也会改变框架

    这些变化的规则是什么

    由struct and springs 决定

    你们的drawRect 不会被重新调用

    set a view's struts and springs in size inspector in Xcode

    structs and springs 的功能是什么?

    grows and shrinks as its supperview's bounds grow nd shrink because structs fixed to all sides and both spring

    有些事情是struct and spring 无法做的

    use code

    didRotateToUIOrientation

    willAnimateToUIRotation

    当视图边界发生变化

    struct and springs 使视图变宽时,你的默认视图会怎 样?

    它会重新调用drawRect吗

    不会

    redraw an bounds change?

    the bit of your view will be stretched or squished or moved.

    位图会变得有点粗糙。


    有一个名为ContentMode的属性

    用来描述视图在边界改变后的变化

    三种模式

    ContentModleleft  right  top

    ContentModebottomright bottomleft

    所有表示方位的模式将视图的位图移动到指定位置

    我在视图变宽之前要如何处理位图

    Scale   ToFill    AspectFill  AspectFit  可以拉伸视图位图的像素

    redraw

    ContentStretch 允许你在视图中指定矩形

    指定一个需伸缩的长矩形,  


    Initializing a UIView

    设置自定义视图的某些初始状态  需要一些状态设置

    ContentMode

    self = [super initWithFrame]

    但问题是当你的视图从故事板中跳出时

    它的initWithFrame没有被调用

    在跳出时都会伴随着一个故事板,

    awakeFromNib实现初始化

    protocols     新的语法

    @interface

    没有对应的@implementation吧

    协议的执行过程发生在其他对象中

    协议紧紧是一个属性的方法集

    请求其它对象来执行协

    你的协议依赖于其它协议

    必选协议定义和创建

     有一个委托, 将多个方法传给它的委托,并定义协议被 ScrollView.h

    可以放在别的头文件里,也可以自成一体

    @interface未尾 使用<标记以执行协议

    #import "foo.h"

    @interface MyClass : NSObject <foo>

    @end

    执行foo里所有方法

    you must implement all non-@optional methods

    we can then declare id variables with a protocol requirement

    id <foo> obj = [[Myclass alloc] init];

    id就是指向未知类型对象的指针

    Also can declare arguments to methods to require a protocol

    - (void)giveMeFooObject:(id <foo>anObjectTemplementingFoo;

    @property (nonatomic ,weak))

    Just like satic typing , this is all just compiler-helping -you stuff

    an documentation for your method interfaces

    use of protocols in IOS delegates and data sources

    视图永远不知道控制器的类

    以弱属性来创建委托

    将它的指回指针指向nil

    UIGestureRecognizer

    we've seen how to draw in our UIView ,how do we get touches?

    rawevents

    Gestures are recognized by the class UIGestureRecognizer

    是一个对象它会观窗视图中的触摸事件,手势类型匹配

    比指绽 放, 滑动或平移

    处理器

    基类是UIGestureRecognizer

    创建一个手势识别器并连接至视 图,

    在识别手势后再处理它

    由控制器完成

    发生时是由视图完成

    如果在处理一些修改模型的,,控制器会处理

    控制器负责加手势,视图也有可能自己加手势

    A 工表格遥秋工UIV 工C火田田

    平移手势识别器

    how do we impement the target of a gesture recognizer?

    UIPaGestureRecognizer

    translationView

    velocityInView

    setTranslation

    位移,速度, 重

    state one important property

    Possible   recogized

    Begin  END

  • 相关阅读:
    《梦断代码》随笔第1篇
    四则运算3
    1、软件工程结对开发之求一维数组中连续最大子数组之和
    四则运算2单元测试
    《梦断代码》随笔第0篇
    四则运算2完整版
    四则运算2设计思想
    软件工程第一个程序
    软件工程阅读计划
    电梯调度之需求分析
  • 原文地址:https://www.cnblogs.com/yushunwu/p/2687071.html
Copyright © 2011-2022 走看看