在您的 WTAppDelegate.m 更改 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
跟随
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
WordsViewController *viewController = [[WordsViewController alloc] init];
[[self window] setRootViewController:viewController];
[self.window makeKeyAndVisible];
return YES;
}
注释掉 WordsViewController.m 中的以下方法
- -(id)initWithStyle:(UITableViewStyle)style
- -(id)初始化
- -(UIView *)headerView
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
无需添加 loadView 方法。
在 WordsViewController.m 中将以下内容添加到 - (void)viewDidLoad
添加
wordsHeaderView = [[[NSBundle mainBundle] loadNibNamed:@"WordsHeaderView" owner:self options:nil] lastObject];
self.tableView.tableHeaderView = wordsHeaderView;