0

这里的任何人都可以告诉我以下是否是从基类继承类的正确方法。

谢谢。

// BaseController.h
@interface BaseController: UIViewController
{
  IBOutlet UITextField* m_pNameTxtFld;
}
@property (nonatomic, retain) IBOutlet UITextField* m_pNameTxtFld;

// BaseController.m

-(void) viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
   if (self.m_pNameTxtFld)
   {
     self.m_pNameTxtFld = nil;
   }
}

// 新控制器.h

@interface NewContorller: BaseController
{
}

// 新控制器.m

@implementation NewContorller

- (void)viewDidLoad

{
  self.m_pNameTxtFld.text = @"Test";
}
4

1 回答 1

1

Yes it is the right way. Just remember that you should call [super viewDidLoad] at the beggining of viewDidLoad implementation in subclass.

- (void)viewDidLoad {
    [super viewDidLoad];
    self.m_pNameTxtFld.text = @"Test";
}
于 2013-05-11T08:09:03.940 回答