自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone編程添加遞進(jìn)式子視圖實(shí)例學(xué)習(xí)

移動(dòng)開發(fā) iOS
iPhone編程添加遞進(jìn)式子視圖實(shí)例學(xué)習(xí)是本文要介紹的內(nèi)容,主要是來系統(tǒng)的來學(xué)習(xí)iphone編程中的一些細(xì)節(jié)問題,來看本文內(nèi)容詳解。

iPhone編程添加遞進(jìn)式子視圖實(shí)例學(xué)習(xí)是本文要介紹的內(nèi)容,主要是來系統(tǒng)的來學(xué)習(xí)iphone編程中的一些細(xì)節(jié)和視圖的相關(guān)問題,來看本文內(nèi)容詳解。iPhone編程中心采用兩種重要的范型:

面向?qū)ο蠓缎?/strong>

模型-視圖-控制器(MVC)設(shè)計(jì)模式

iPhone上的MVC劃分:

視圖       

由UIView類以及子類以及其相關(guān)的UIViewController類提供。PS:關(guān)于此處Controller,個(gè)人認(rèn)知為一個(gè)容器,用于保存UIView類的實(shí)例,同時(shí)負(fù)責(zé)對屏幕中各項(xiàng)進(jìn)行布局。

控制器      
 
通過3中關(guān)鍵技術(shù)實(shí)現(xiàn):委托、目標(biāo)操作和通知

模型      
 
模型方法拖過數(shù)據(jù)源和數(shù)據(jù)含義等協(xié)議提供數(shù)據(jù),需要實(shí)現(xiàn)由控制器觸發(fā)的回調(diào)方法。

實(shí)例學(xué)習(xí)

在實(shí)踐Pdf版書中P47的例子中,通過蘋果官網(wǎng)資料學(xué)習(xí):

UIView類

常用屬性:

  1. superview  
  2. subviews  
  3. window  
  4. autoresizingMask UIViewAutoresizing常量,
  5. 常用UIViewAutoresizingFlexibleWidth and UIViewAutoresizingFlexibleRightMargin  
  6. autoresizesSubviews    標(biāo)記子視圖是否自動(dòng)重設(shè)大小  
  7. tag    標(biāo)識(shí)視圖的標(biāo)簽 

常用方法:

  1. addSubview  
  2. insertSubview  
  3. removeFromSuperview  
  4. viewWithTag    通過標(biāo)識(shí)獲取視圖指針 

UIViewController類

為蘋果應(yīng)用程序提供基本的view-management(視圖管理)模型。

UINavigationController,UITabBarController是此類的子類,提供額外行為操作來管理復(fù)雜層次關(guān)系視圖控制器和視圖。

常用屬性:

view:

當(dāng)前控制器管理的視圖,為控制器當(dāng)前可見的視圖

常用方法:

loadView:

創(chuàng)建視圖用于控制器使用。

willRotateToInterfaceOrientation:

用于屏幕翻轉(zhuǎn)告知控制器,以響應(yīng)對應(yīng)的改變

shouldAutorotateToInterfaceOrientation:

返回一個(gè)Bool值,來指示當(dāng)前視圖控制器是否支持指定的方向   

此函數(shù)涉及一個(gè)常量,如下:

UIInterfaceOrientation常量:

  1. typedef enum {  
  2.    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,  
  3.    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,  
  4.    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,  
  5.    UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft 
  6. } UIInterfaceOrientation; 

用于判斷用戶的屏幕橫放和豎放是否支持。比如:看視頻,一般都是橫起看,那么取值只能UIDeviceOrientationLandscapeRight UIDeviceOrientationLandscapeLeft。完整代碼如下:

  1. // Allow the view to respond to 2 iPhone Orientation changes,like:  
  2. -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation  
  3. {  
  4.     return (interfaceOrientation == UIDeviceOrientationLandscapeRight || interfaceOrientation == UIDeviceOrientationLandscapeLeft);  

幾何類型結(jié)構(gòu):

CGRect

  1. A structure that contains the location and dimensions of a rectangle.  
  2.  
  3.     struct CGRect {  
  4.        CGPoint origin;  
  5.        CGSize size;  
  6.     };  
  7.     typedef struct CGRect CGRect; 

CGPoint

  1. A structure that contains a point in a two-dimensional coordinate system.  
  2.  
  3.     struct CGPoint {  
  4.        CGFloat x;  
  5.        CGFloat y;  
  6.     };  
  7.     typedef struct CGPoint CGPoint; 

CGSize

  1. A structure that contains width and height values.  
  2.  
  3.     struct CGSize {  
  4.        CGFloat width;  
  5.        CGFloat height;  
  6.     };  
  7.     typedef struct CGSize CGSize; 

CGFloat

  1. The basic type for all floating-point values.  
  2. typedef float CGFloat;// 32-bit  
  3. typedef double CGFloat;// 64-bit 

小結(jié):iPhone編程添加遞進(jìn)式子視圖實(shí)例學(xué)習(xí)的內(nèi)容介紹完了,希望本文能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 博客園
相關(guān)推薦

2011-07-22 17:24:46

iPhone 視圖

2011-07-18 15:32:14

iPhone 錄音 播放

2011-08-11 16:19:11

iPhoneCocoa

2011-08-15 18:02:32

iPhone開發(fā)表視圖

2011-07-26 15:56:53

iPhone 游戲 啟動(dòng)畫面

2011-08-08 15:56:18

iPhone 震動(dòng) NSUserDefa

2011-07-28 14:19:12

iPhone 網(wǎng)絡(luò)編程 聊天程序

2021-04-30 18:50:44

網(wǎng)絡(luò)安全PE編程添加節(jié)區(qū)

2011-07-21 17:29:42

iPhone Sqlite 數(shù)據(jù)庫

2009-09-23 15:12:41

Hibernate視圖

2011-07-25 18:02:51

iPhone LibFetion 移植

2011-07-29 10:51:41

iPhone 全屏顯示 視圖

2011-08-12 11:23:47

iPhone窗口視圖

2011-07-27 17:45:29

iPhone 模擬器 圖片

2011-07-21 16:48:19

iPhone 游戲

2009-08-28 17:51:40

iPhone多視圖開發(fā)

2011-08-08 16:56:44

iPhone 字符處理 視圖

2011-08-12 10:04:24

iPhone開發(fā)視圖

2011-07-18 13:37:53

2011-07-06 16:15:46

iPhone 圖片
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)