博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
View
阅读量:6248 次
发布时间:2019-06-22

本文共 2740 字,大约阅读时间需要 9 分钟。

A view(UIView subclass) represents a rectangular area.

a view has only one superview - (UIView *) superview;

But can have many(or zero) subviews -(NSArray *) subviews;

subview order matters.

 

UIWindow

the UIView at the top of the view hierarchy.

Only have one UIWindow in an iOS application.

It is all about UIViews.

always use CGFloat for graphics. 

CGPoint p = CGPointMake(34.5,22.0);p.x += 20; CGSize CGSizeMake CGRect CGRectMake

coordinate system is upper left -----> x 

units are "points" not pixels!

@property CGFloat contentScaleFactor

view's 3 properties

@property CGRect bounds;//internal@property CGPoint center;//the center in your superview's coordinate system@property CGRect frame;// a rectangle in your superview's coordinate space which entirely contains your view's bounds.size

when view rotated, bounds and frame are different.

to customize view

drag out a generic UIView from the palette and use the Inspector to change the class of the UIView to your custom class.

autorotation

implement the following method in your controller

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) orientation{}

content mode

By default, when your UIView's bounds change, no redraw.

luckily, there is a UIView @property to control this.

@property (nonatomic) UIViewContentMode contentMode;

Default is UIViewContentModeScaleToFill.

protocol

@protocol Foo 
- (void) doSomething;@optional@required@property@end

UIGestureRecognizer

how can we react to certain "gestures"?

there are two steps to using a gesture recognizer

  • adding a gesture recognizer to a UIView
  • provide a gesture handler

 

UIViewController

mvcs working together

how do we switch the screen to show another mvc

controller of controller

UINavigationController

it's special because we can set its rootViewController outlet to another MVC...

A UI element in a view can segue to the other MVC and its view will now appear in the UINavigationController

to create a segue, you hold down ctrl and drag from the button to the other view controller.

Is Initial View Controller

Embedded in Navigation Controller

UIView obtained from the view property of the UIViewController most recently pushed (or root).

NSString obtained from the title property of the UIViewController most recently pushed (or root).

An NSArray of UIBarButtonItems obtained from the toolbarItems property of the UIViewController most recently pushed.

back button -- title property of the previous view

- (IBAction) rentEquipment{    if(self.snowTraversingTalent ==Skiing){         [self performSegueWithIdentifier:@"AskAboutSkis" sender:self];    }}

prepareForSegue

- (void) prepareForSegue: (UIStoryboardSegue *) segue{}

 

 

 

转载于:https://www.cnblogs.com/grep/archive/2012/04/22/2464712.html

你可能感兴趣的文章
MinGW 介绍
查看>>
MATLAB中导入数据:importdata函数
查看>>
bsearch的溢出问题
查看>>
在windows server2003下安装Redmine
查看>>
mysql 加入列,改动列,删除列。
查看>>
HTTPWatch使用
查看>>
如何确定照片是否被PS过
查看>>
Reverse Nodes in k-Group
查看>>
使用android快速开发框架afinal的FinalDb操作android数据库
查看>>
在SSH框架中使用Spring的好处(转)
查看>>
【MATLAB】读取和写入文本文件
查看>>
Android中实现Launcher功能之二 ----- 添加窗口小部件以及AppWidget的创建详解
查看>>
Handler sendMessage 与 obtainMessage (sendToTarget)比较
查看>>
Working in Singapore
查看>>
php发送get、post请求的几种方法
查看>>
Linux多线程同步方式
查看>>
【Spark亚太研究院系列丛书】Spark实战高手之路-第一章 构建Spark集群(第五步)(2)...
查看>>
2015第9周二
查看>>
Android监听外部存储设备的状态(SD卡、U盘等等)
查看>>
Execute Javascript in iOS Applications
查看>>