1

完全按照教程,我创建了扩展 UITableViewController 的文件。问题是他的 uitableviewcontroller.m 文件充满了预先编写的代码(如 viewDidLoad),而我的完全空白!我们的 uitableviewcontroller.h 文件都有代码

#import <UIKit/UIKit.h>

@interface ChemTable : UITableViewController
@property (strong,nonatomic)NSMutableArray *Chemarray;


@end
4

1 回答 1

1

出于学习目的,自动生成的方法使用最少(即使您将其删除也完全可以)。即使您可以在没有它们的情况下创建应用程序......“viewDidLoad”是加载视图时运行的一种非常必要的方法,但是当您使用真正的应用程序时,您肯定会使用一些自动生成的方法。

额外 --> 我想你也应该看到这个: ViewDidLoad - 当你创建类并从 xib 加载时调用。非常适合初始设置和一次性工作

ViewWillAppear - Called right before your view appears, good for hiding/showing fields or any operations that you want to happen every time before the view is visible. Because you might be going back and forth between views, this will be called every time your view is about to appear on the screen

ViewDidAppear - Called after the view appears - great place to start an animations or the loading of external data from an API.

ViewWill/DidDisappear - Same idea as the WillAppear.

ViewDidUnload/Dispose - Available to you, but usually not necessary in Monotouch. In objective-c, this is where you do your cleanup and release of stuff, but this is handled automatically so not much you really need to do here.
于 2012-11-03T04:11:49.953 回答