00a- WalkThrough

  • warning: Declaration of views_handler_argument::init(&$view, &$options) should be compatible with views_handler::init(&$view, $options) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 745.
  • warning: Declaration of views_handler_filter::options_validate(&$form, &$form_state) should be compatible with views_handler::options_validate($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • warning: Declaration of views_handler_filter::options_submit(&$form, &$form_state) should be compatible with views_handler::options_submit($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • warning: Declaration of views_handler_filter_boolean_operator::value_validate(&$form, &$form_state) should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 149.
  • warning: Declaration of views_plugin_style_default::options(&$options) should be compatible with views_object::options() in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_style_default.inc on line 25.
  • warning: Declaration of views_plugin_row::options_validate($form, &$form_state) should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.
  • warning: Declaration of views_plugin_row::options_submit($form, &$form_state) should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.

iPhone SDK開發範例大全第三章之二Walk Through(2/8):2009年09月07a日星期一

iPhone SDK開發範例大全即iPhone Developer's CookBook的中文譯本,程式可由erica網站下載。第三章講View Controller,程式共有七個。

本文講第1個程式00a- WalkThrough,CookBook 中文譯本3-2、109頁(訣竅3-2):

(A) 本程式用View Controller概念及UIViewController Class,來做華氏、攝氏度數轉換。如下圖。

(B)依據書上步驟,在Xcode中:

    1. File/New Project/Cocoa Touch Application View-Based,並命名為WalkThrough專案(project)。
      • 在Xcode 3.1.1應為--File/New Project,出現New Project畫面,再選左iPhone OS/Application後出現template,選View-based Application。
    2. 將Class folder刪除。
    3. 打開main.m,並將書上p110的程式碼放進去。

之後,

我加入了#pragma,接著click Xcode的menu bar上的(上下arrow)看Function Menu,共有MyView、MyViewController、WalkThroughAppDelegate三個class及一個main() function,如下:

注意:依照書上所言去掉Class folder並不夠clean, 再去掉jWalkThrough.app及jWalkThroughViewController.xib(此例以jWalkThrough為project名)。但jWalkThrough_prefix.pch及jWalkThrough-info.plist不能去掉。

(C)接著,

  1. 照書上p111起、3、4所說,double click MainWindow.xib,會出現MainWindow.xib畫面,並有五個icon,File's Owner、First Responder、Application Delagate(以本例,為Walk Through App Delegate)、Window、My View Controller。
    • 書上p112圖3-2不對,只出現3個icon,少了First Respnder及Walk Through View Controller。
  2. 再依書上p113、5、6所說,將Application Delagate名字設好。
  3. 再依p113、7所說將window及contentView這兩個outlet加入Application Delegate內。
  4. 再依照p114、8、9加入UIViewController及UIView。
    • (注意:原來已有一個controller -- Walk Through View Controller,先delete掉,事實上圖3-4不對,應有六個icon,少了First Responder)。
  5. 再依p115、10將outletb infield、outfield及action convert:加入。
  6. 再依p115、11將兩個UILabel、一個UIButton、兩個Field加入。
  7. 再依p116、12加入水平垂直導引線。
  8. 再依p116、13將Walk Through Application Delegate內的contentView及window兩outlet連好。
  9. 再依p117、15將MyView內的infield、outfield兩outlet連好。再依p117、16將MyView內的convert: action連好。
  10. 最後依p118、17將MyView放入My View Controller內。

如此才完成,一步都不能少,如下圖:

(D)看一下(C)9連好MyView的各connection。

(E)看一下最後的檔案。

(F)看一下MyView class。內有instance variable infield、outfield及action convert:。

(G)MyViewController class。

(H)WalkThroughAppDelegate class。內有window及contentView instance variable。

(I)問題點:(B)第二圖中.pch檔的名稱不能改,若要改.pch檔,該如何改?