成功拿到token 后,我们需要去获取新闻列表。为了简单化,我们直接跳过了中间取新闻分类的过程,hard code 某个新闻分类。
从登录页面跳转到我们当前的新闻列表界面。
先建立一个NewsListViewController。UINavigationController 就用我们storyboards 里面自带那个实现跳转。
一个简单的UITableView, 每列元素为一个图片,标题,概要,发布时间。点击跳转到详情页面。
这次我们用代码的形式去实现这个布局。
未完待续
table view 是一个上下滚动的view. 由分割开的sections 组成。每个section 由rows 组成。其中每行是UITableViewCell class 的一个实例。当然我们可以通过继承该class 实现自定义的UITableViewCell.
有两种方式使用Table View.
不用想了,我们日常中就是用第二种方式。看构造函数:
initWithFrame:style:
看看UITableViewDelegate 接口中有哪些好用的东东:
tableView:viewForHeaderInSection:
tableView:viewForFooterInSection:
tableView:didEndDisplayingCell:forRowAtIndexPath:
tableView:willDisplayCell:forRowAtIndexPath:
和数据显示相关的东东:
numberOfSectionsInTableView:
tableView:numberOfRowsInSection:
tableView:cellForRowAtIndexPath:
随便先搭起框架:
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.tableView =
[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.tableView.dataSource = self;
self.tableView.autoresizingMask =
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.tableView];}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 20;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [[UITableViewCell alloc]init];
cell.textLabel.text = @"123";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}