#import "SAHomeController.h"
#import "NSString+SA.h"
#import "UIBarButtonItem+SA.h"
#import "SAStatus.h"
#import "SAStatusTool.h"
@interface
SAHomeController ()
{
NSArray
*_status;
}
@end
@implementation
SAHomeController
- (
id
)initWithStyle:(UITableViewStyle)style
{
self
= [
super
initWithStyle:style];
if
(
self
) {
}
return
self
;
}
- (
void
)viewDidLoad
{
[
super
viewDidLoad];
_status = [
NSMutableArray
array];
[
self
loadBasicUI];
[
self
loadStatusData];
}
#pragma mark 加载基本界面
- (
void
)loadBasicUI
{
self
.title =
@"首页"
;
self
.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonItemWithImageName:
@"navigationbar_compose.png"
highLightedImageName:
@"navigationbar_compose_highlighted.png"
addTarget:
self
action:
@selector
(leftButtonClick) forControlEvents:UIControlEventTouchUpInside];
self
.navigationItem.rightBarButtonItem = [UIBarButtonItem barButtonItemWithImageName:
@"navigationbar_pop.png"
highLightedImageName:
@"navigationbar_pop_highlighted.png"
addTarget:
self
action:
@selector
(rightButtonClick) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark 加载微博数据
- (
void
)loadStatusData
{
[SAStatusTool statusToolGetStatusSuccess:^(
NSArray
*array) {
_status = [
NSArray
arrayWithArray:array];
[
self
.tableView reloadData];
} failurs:^(
NSError
*error) {
MyLog(
@"%@"
, [error localizedDescription]);
}];
}
#pragma mark 首页导航左按钮事件
- (
void
)leftButtonClick
{
MyLog(
@"首页左按钮"
);
}
#pragma mark 首页导航右按钮事件
- (
void
)rightButtonClick
{
MyLog(
@"首页右按钮"
);
}
#pragma mark - Table view data source
- (
NSInteger
)tableView:(UITableView *)tableView numberOfRowsInSection:(
NSInteger
)section
{
return
_status.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(
NSIndexPath
*)indexPath
{
static
NSString
*Identifier =
@"Cell"
;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
if
(!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Identifier];
}
SAStatus *status = _status[indexPath.row];
cell.textLabel.text = status.user.screenName;
cell.detailTextLabel.text = status.text;
return
cell;
}
@end