mirror of
https://github.com/wu736139669/ManagerDemo.git
synced 2026-08-07 06:14:48 +00:00
mainview
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
//
|
||||
|
||||
#import "HomeViewController.h"
|
||||
|
||||
#import "MJRefresh.h"
|
||||
#import "HomeAdView.h"
|
||||
@interface HomeViewController ()
|
||||
|
||||
@end
|
||||
@@ -28,8 +29,82 @@
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
[self.navigationItem setTitle:@"首页"];
|
||||
|
||||
//左边按钮
|
||||
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"左边按钮" style:UIBarButtonItemStyleDone target:self action:@selector(leftBarBtnClick:)]];
|
||||
|
||||
//右边按钮。
|
||||
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(rightBarBtnClick:)]];
|
||||
|
||||
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
[_tableView addHeaderWithTarget:self action:@selector(headerRereshing)];
|
||||
// [_tableView addFooterWithTarget:self action:@selector(footerRereshing)];
|
||||
|
||||
[_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark MJRefreshDelegate
|
||||
- (void)headerRereshing
|
||||
{
|
||||
|
||||
// 2.2秒后刷新表格UI
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// 刷新表格
|
||||
[self.tableView reloadData];
|
||||
|
||||
// (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
|
||||
[self.tableView headerEndRefreshing];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)footerRereshing
|
||||
{
|
||||
|
||||
// 2.2秒后刷新表格UI
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// 刷新表格
|
||||
[self.tableView reloadData];
|
||||
|
||||
// (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
|
||||
[self.tableView footerEndRefreshing];
|
||||
});
|
||||
}
|
||||
#pragma mark UITableViewDelegate
|
||||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
return 1;
|
||||
}
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
return 1;
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *homeViewCell = @"HomeViewCell";
|
||||
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:homeViewCell];
|
||||
if (cell == nil) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:homeViewCell];
|
||||
HomeAdView* homeAdView = [[HomeAdView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 120)];
|
||||
[cell addSubview:homeAdView];
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
#pragma mark - UIBarButtonClick 导航条两边按钮
|
||||
-(void)leftBarBtnClick:(id)sender
|
||||
{
|
||||
DLog(@"首页左边按钮");
|
||||
}
|
||||
-(void)rightBarBtnClick:(id)sender
|
||||
{
|
||||
DLog(@"首页右边按钮");
|
||||
[_tableView headerBeginRefreshing];
|
||||
}
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
|
||||
Reference in New Issue
Block a user