完全按照教程,我创建了扩展UITableViewController的文件。问题是他的uitableviewcontroller.m文件填充了预先编写的代码(如viewDidLoad),而我的文件完全是空白的!我们的uitableviewcontroller.h文件都具有
的代码#import <UIKit/UIKit.h>
@interface ChemTable : UITableViewController
@property (strong,nonatomic)NSMutableArray *Chemarray;
@end
答案 0 :(得分:1)
出于学习目的,自动生成的方法使用最少(即使将其删除也完全可以)。甚至你可以在没有它们的情况下创建应用程序......“viewDidLoad”是加载视图时运行的一种非常必要的方法,但是当你选择真正的应用程序时,你肯定会使用一些自动生成的方法。
额外 - &gt;我想你也应该看到这个: 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.