• ios UIView和UIviewController


    UIView 是界面层button title等的容器

    UiViewContriller负责创建和销毁/显示和隐藏UiView。处理UiView用户之间的交互 事件处理

    用户录入界面(所有交互界面)都在创建UiViewContriller之前发生

    即先创建一个UiViewContriller,再有这个UiViewContriller创建自己的UiView ,最后把UiView展示给用户。

    关于监听事件

    就是说让程序中方法或类等待一个事情发生然后做出相应的操作。例如用户按下按钮,对应方法里面做出响应操作。又如单击一个页面发生时弹出新的页面窗口等等

    Xcode不会自动像VS一样布局界面的时候自动生成一份对象

    它实现了前台界面和后台代码的弱关系,需要手工方式来实现对象的挂接

    原则:当UI类文件需要和一个界面的对象或事件直接交互的时候,使用IBOutlet、IBAction关键字来告知编译器。

    下面一段英文资料
    Making the AppController @interface
    We’ll use the Interface Builder application to lay out the window’s contents and hook up various
    connections between AppController and the user interface controls. Interface Builder
    is also used to lay out iPhone applications, so time in Interface Builder is well spent no matter
    which platform you’ll end up programming for. We’ll add stuff to the AppController
    class, and then Interface Builder will notice our additions and let us build the user interface.
    First, we’ll set up the header file for AppController:

     1 #import <Cocoa/Cocoa.h>
     2 @interface AppController : NSObject 
     3 {
     4 IBOutlet NSTextField *textField;
     5 IBOutlet NSTextField *resultsField;
     6 }
     7 - (IBAction) uppercase: (id) sender;
     8 - (IBAction) lowercase: (id) sender;
     9 @end 
    10 // AppController

    There are two new quasi- keywords in there: IBOutlet and IBAction. These are actually just
    #defines provided by the AppKit. IBOutlet is defined to be nothing, so it disappears when
    we compile. IBAction is defined to be void, which means the return type of the methods
    declared in AppController will be void (that is, returning nothing).
    If IBOutlet and IBAction don’t do anything, why are they even there? The answer is that
    they’re not there for the compiler: IBOutlet and IBAction are actually flags to Interface
    Builder, as well as the humans who read the code. By looking for IBOutlet and IBAction,
    Interface Builder learns that AppController objects have two instance variables that can
    be connected to stuff, and AppController provides two methods that can be the target of
    button clicks (and other user interface actions). We’ll talk about how this works in a little bit.
    In Interface Builder, we’ll connect the textField instance variable to an NSTextField
    object. This text field is where users will type strings to be converted, which is the typical
    role for an NSTextField.
    resultsField will be connected to a read- only NSTextField. When in read- only mode,
    an NSTextField acts like a text label. This text label is where the uppercase or lowercase
    version of the string will be displayed.

    这段来自《Learn.Objective-C.on.the.Mac》英文版,14章节。

    ios UIVew常见属性 按钮 图片浏览器

    官方API

     1 @interface UIView(UIViewGeometry)
     2 分类
     3 // animatable. do not use frame if view is transformed since it will not correctly reflect the actual location of the view. use bounds + center instead.
     4 @property(nonatomic) CGRect            frame;
     5 
     6 // use bounds/center and not frame if non-identity transform. if bounds dimension is odd, center may be have fractional part
     7 @property(nonatomic) CGRect            bounds;    
     8   // default bounds is zero origin, frame size. animatable
     9 @property(nonatomic) CGPoint           center;    
    10   // center is center of frame. animatable
    11 @property(nonatomic) CGAffineTransform transform;  
    12  // default is CGAffineTransformIdentity. animatable
     1 /* Rectangles. */
     2 结构体
     3 struct CGRect {
     4   CGPoint origin;
     5   CGSize size;
     6 };
     7 typedef struct CGRect CGRect;
     8 
     9 /* Rectangle edges. */
    10 /* Points. */
    11 
    12 struct CGPoint {
    13   CGFloat x;
    14   CGFloat y;
    15 };
    16 typedef struct CGPoint CGPoint;
    17 
    18 /* Sizes. */
    19 
    20 struct CGSize {
    21   CGFloat width;
    22   CGFloat height;
    23 };
    24 
    25 struct CGAffineTransform {
    26   CGFloat a, b, c, d;
    27   CGFloat tx, ty;
    28 };

    1>frame

    表示控件位置和尺寸,以父控件左上角为坐标原点

    2>bounds

    表示控件位置和尺寸,以自身左上角为坐标原点

    3>center

    任意一个控件的最中心 的 中点坐标

    4>tag

    标识。用于区分不同控件类似ID

    5>superview

    获取父控件

    6>subviews

    控件数组 (NSString *)subviews

    7>transform

    形变属性。(动画经常用)

    无论生活、还是技术,一切都不断的学习和更新~~~努力~
  • 相关阅读:
    The "tsconfig.json" file must have compilerOptions.sourceMap set to true
    *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<WKWebViewConfiguration 0x1701bcd20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the k
    Android Service
    关于phonegap-plugin-contentsync插件
    Ionic APP 热更新 之 产品发布状态下的热更新搭建,去local-dev-addon插件
    Ionic APP 热更新
    在懒加载的Ionic工程中使用 ionic2-auto-complete 组件:Can't bind to 'dataProvider' since it isn't a known property of 'ion-auto-complete'
    Template parse errors: The pipe 'translate' could not be found
    How to update Ionic cli and libraries
    第七章 Hyper-V 2012 R2 授权管理
  • 原文地址:https://www.cnblogs.com/zhangdashao/p/4474588.html
Copyright © 2020-2023  润新知