第三课 (5)继承

  我们要为列表页添加标题

要怎么做呢?

首先新建BaseViewController,并设置绿色标题栏,灰色背景

删除ViewController中与之重复的代码

让相关对象继承BaseViewController

BaseViewController提供方法,以供子类设置标题

 

 

1.新建一个文件

ios——Source——Cocoa Touch Class

要说明是谁的子类,我们这里是继承自UIViewController。

起名为BaseViewContraoller,把前面写的代码粘贴BaseViewContraoller.m下

在ViewController下接口接自BaseViewControll。

 

 创建一个列表页,如上名字为MomentListViewCotroller

 


UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].
bounds.size.width, [UIScreen mainScreen].bounds.size.height-64)]; [self.view addSubview:tableView];

  制作表单

self.automaticallyAdjustsScrollViewInsets = NO

  不需要自动调整表单位置

 

posted @ 2017-02-26 16:21  racher  阅读(78)  评论(0编辑  收藏  举报