成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Xcode 學習之路 Interface Builder使用技巧

移動開發(fā) iOS
本文介紹的是Xcode 學習之路 Interface Builder使用技巧,在壇子里面逛,發(fā)現(xiàn)了這么一排呢好文章,與大家分享一下。

最近在看電驢上down下來的ipad開發(fā)視頻教程。為加深記憶,特在此做筆記。

前兩集視頻主要講的是UIAlertView(相當于windows里面的MessageBox)

在interface builder里面添加了控件之后,要想使得控件響應(yīng)事件必須做如下處理:

1:在XXXViewController.h里面添加事件響應(yīng)函數(shù)聲明如:

  1.   -(IBAction)btnOnclick:(id)sender; 

2:在相應(yīng)的.m文件中實現(xiàn)這個函數(shù)

3:回到interface builder中鼠標右鍵從需要使用這個事件相應(yīng)函數(shù)的控件拖拽到File's Owner上并在彈出的選項中選中步驟1中的函數(shù)名,使之關(guān)聯(lián)起來。

Xcode 學習之路 Interface Builder使用技巧

注意:這個視頻里面提到了一個特別的控件就是UIAlertView,因為這個控件沒有在interface builder中提供出來編輯。所以如果這個要使這個控件的事件得到相應(yīng)需要在XXXViewController.h文件里面聲明類的時候使用協(xié)議(類似C++里面的抽象基類的多重繼承)。樣子如下:

  1. #import <UIKit/UIKit.h> 
  2. @interface AlertViewTestViewController : UIViewController <UIAlertViewDelegate>{  
  3. }  
  4. @end 

然后在實現(xiàn)文件里面實現(xiàn)對應(yīng)的事件處理函數(shù)。對UIAlertView來說。要使用的協(xié)議是UIAlertViewDelegate,要實現(xiàn)的事件響應(yīng)函數(shù)是 - (void)alertView:(UIAlertView* )alertView clickedButtonAtIndex:(NSInteger)buttonIndex。實際上,使用了協(xié)議之后,可以根據(jù)協(xié)議名字在幫助里面很快的找到這個協(xié)議需要實現(xiàn)哪些函數(shù)。

控件還有另外一個比較重要的東西就是數(shù)據(jù)綁定。在xcode里面要實現(xiàn)這么一個東西步驟基本和上面的類似

1:在XXXViewController.h文件里面聲明之,下面聲明了一個文本數(shù)據(jù)

  1. @interface OutletAndActionViewController : UIViewController {  
  2.     IBOutlet UITextField *txtName;  
  3. }  
  4. @property(nonatomic, retain) UITextField *txtName;  
  5. @end 

2:實現(xiàn)文件里面給出set和get函數(shù)。如果使用了屬性,你懂的。。。

  1. @synthesize txtName; 

3:回到interface builder中鼠標右鍵從File's Owner中拖拽到需要綁定這個數(shù)據(jù)的控件上并在彈出的選項中選中,使之關(guān)聯(lián)起來。拖拽方向和上面相反。寫到這里。我在想IBAction和IBOutlet到底是個啥?

Xcode 學習之路 Interface Builder使用技巧

在頭文件中找到了他們的定義:

  1. #ifndef IBOutlet   
  2. #define IBOutlet   
  3. #endif  
  4.  
  5. #ifndef IBAction   
  6. #define IBAction void   
  7. #endif 

幾乎啥都沒干。最后在cocoachina上找到了答案。

原帖:http://www.cocoachina.com/bbs/read.php?tid-18829.html

內(nèi)容如下:

These two keywords do absolutely nothing as far as the compiler is concerned. IBOutlet gets entirely removed from the code before the compiler ever sees it. IBAction resolves to a void return type, which just means that action methods do not return a value. So, what’s going on here?
The answer is simple, really: IBOutlet and IBAction are not used by the compiler. They are used by Interface Builder. Interface Builder uses these keywords to parse out the outlets and actions available to it. Interface Builder can only see methods that are prefaced with IBAction and can only see variables or properties that are prefaced with IBOutlet. Also, the presence of these keywords tells other programmers, looking at your code in the future, that the variables and methods in question aren’t dealt with entirely in code. They’ll need to delve into the relevant nib file to see how things are hooked up and used.

敢情這兩關(guān)鍵字完全是給interface builder看的。

小結(jié):Xcode 學習之路 Interface Builder使用技巧 的內(nèi)容介紹完了希望本文對你有所幫助!

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

2011-08-03 14:13:45

Xcode 4 Interface

2011-07-20 09:49:41

Xcode Interface Builder

2011-07-28 13:47:20

Xcode Interface

2011-07-06 15:06:46

Xcode Cocoa

2011-08-05 10:01:23

Xcode Interface

2011-07-06 15:14:34

iOS Xcode

2011-08-11 16:31:08

XCode

2011-07-25 10:30:41

Objective-C Xcode 重構(gòu)

2011-07-25 11:02:29

Objective-C Xcode 標簽

2011-07-25 10:14:13

Objective-C Xcode

2011-08-05 09:38:46

Interface B Cocoa 界面

2011-08-19 15:16:41

XCodeUserScripts腳本

2011-07-20 14:31:56

XCode User Scrip 腳本

2011-08-08 17:05:02

XCode UserScript 腳本

2011-08-05 09:48:46

iPhone Interface

2011-07-22 15:56:18

iPhone Interface Builder

2011-07-26 17:47:13

2013-04-18 10:19:40

iOS開發(fā)Xcode調(diào)試

2011-08-04 18:09:32

Xcode 技巧 文檔

2010-01-11 16:19:05

C++ Builder
點贊
收藏

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

主站蜘蛛池模板: 亚洲国产视频一区二区 | 亚洲性综合网 | 做a视频| 国产日韩欧美综合 | 欧美a区 | 国产情侣啪啪 | 欧美精品一区二区三区蜜臀 | 99精品视频免费在线观看 | 中文字幕第一页在线 | 国产一区二区在线免费观看 | 在线观看三级av | 日韩高清电影 | 黄网站涩免费蜜桃网站 | 亚洲欧美国产一区二区三区 | 超碰成人免费观看 | 久久久123 | 国产精品精品久久久 | 男人天堂视频在线观看 | av看片网站 | 日本免费一区二区三区四区 | 99国产精品99久久久久久粉嫩 | 在线一区二区国产 | 欧美黄色小视频 | 国产不卡视频在线 | 国产黄色av网站 | 久久亚洲免费 | 99热在这里只有精品 | 中文成人无字幕乱码精品 | 成人在线一区二区 | 欧美一区二区免费 | 国产欧美一区二区久久性色99 | 欧美一级片在线看 | 亚洲女人天堂网 | 97视频在线观看免费 | 欧美精品在欧美一区二区少妇 | 爱爱免费视频 | 亚洲天堂一区 | a国产视频| 婷婷开心激情综合五月天 | 黄色大片免费网站 | 伊人影院在线观看 |