0

iOSの見方の違いを順を追って教えてください。どのメソッドが最初に実行されるかなどを説明してください。つまり、どのメソッドがいつ実行されたということですか?

4

2 に答える 2

3
  1. InitまたはInitWithCodeまたはInitWithNibNameまたは(任意の初期化メソッド)
  2. loadView ///カスタムviewControllerがあり、nibFileから代わりにカスタムビューをロードする場合にのみ呼び出されます。通常、loadViewは呼び出されません
  3. viewDidLoad
  4. viewWillAppear
  5. viewDidAppear

アンロード側

  1. viewWillDisappear
  2. viewDidDisappear
  3. viewDidUnload
  4. デアロック

これらはviewControllerに固有であり、tableViewまたは他のタイプのviewControllerには固有ではありません。メソッドplzがない場合は、コメントを追加してください。

于 2011-03-08T06:04:53.197 に答える
0

特定の質問については、viewDidLoadにサブビューを追加する必要があります。loadViewを上書きする場合は、すべてのジョブを実行して、すべてのビューをロードする必要があるためです。

Appleのドキュメントからの説明は次のとおりです。

ロードサイクル中に発生する手順は次のとおりです。

1.

  * Some part of your application asks for the view in the view

controller’s view property.

2.

  * If the view is not currently in memory, the view controller calls its loadView

method.

3.

  * The loadView method does one of the following:

        If you override this method, your implementation is

responsible for creating all necessary views and assigning a non-nil value to the view property.

        If you do not override this method, the default implementation uses 

the nibName and nibBundle properties of the view controller to try to load the view from the specified nib file. If the specified nib file is not found, it looks for a nib file whose name matches the name of the view controller class and loads that file.

        If no nib file is available, the method creates an empty UIView object 

and assigns it to the view property.

4.

  * The view controller calls its viewDidLoad method to perform any

additional load-time tasks.
于 2011-03-08T06:02:47.003 に答える