에 함께 IBOutlet으로의 UIViewController의 서브 클래스의 속성을 사용하여, 우리는이 서브 클래스 프로그래밍 initalized보다있는 jQuery과 속성이, MySuperClass를 호출합니다. 하위 클래스 MySuperClass to MySubclass하지만 이번에는 프로그래밍 방식이 아닌 인터페이스 작성기를 통해 tableview를 디자인하고 싶습니다. 내가 뭘 원하는지 비슷합니다. UIViewController 어떻게 작동합니까, UIViewController의 하위 클래스에 뷰 속성이 이미 초기화되어 있지만 IB에 가져 오면 인터페이스 작성기의 UIView 항목에 연결할 수 있습니다. 어떻게해야합니까?가 나는있는 UIViewController의 서브 클래스가 다른 서브 클래스
//interface
#import <UIKit/UIKit.h>
@interface MySuperClass : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
//implementation
#import "MySuperClass.h"
@implementation MySuperClass
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[self initializeProperties];
}
return self;
}
- (void) awakeFromNib{
[super awakeFromNib];
[self initializeProperties];
}
- (void) initializeProperties{
self.tableView = [[UITableView alloc] initWithFrame: self.view.frame style: UITableViewStylePlain];
self.tableView.separatorColor = [UIColor clearColor];
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.delegate = self;
self.tableView.dataSource = self;
UIView *tableHeaderView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, self.view.frame.size.width, self.bannerView.frame.size.height+kBannerDistance)];
tableHeaderView.backgroundColor = [UIColor clearColor];
self.tableView.tableHeaderView = tableHeaderView;
}
awakeFromNib에 의해 재 활성화되지 않았습니까? –
IB에서 설정된'tableView'는'initializeProperties'에서 초기화 된'tableView'로 대체 될 것입니다. 그래서 기본적으로이 솔루션은 서브 클래스를 쓸모 없게 만들 것입니다. –