All rights reserved.//#import "ViewController.h"#import "IIITableViewController.h"@interface ViewController(){
NSDictionary *dic;
NSArray *arr;
}
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)UIImageView *ImageView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.tableView.dataSource=self;
self.tableView.delegate=self;
self.tableView.contentInset = UIEdgeInsetsMake(200,0,0,0);
_tableView.rowHeight=60;
[self.view addSubview:self.tableView];
self.ImageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"5"]];
self.ImageView.frame = CGRectMake(0, 50 ,self.view.frame.size.width,200);
self.ImageView.contentMode = UIViewContentModeScaleAspectFill;
[self.tableView addSubview:self.ImageView];
NSString *path = [[NSBundle mainBundle]pathForResource:@"QQData.plist" ofType:nil];
dic = [NSDictionary dictionaryWithContentsOfFile:path];
arr = [dic allKeys];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat y = scrollView.contentOffset.y;
if(y < 20){
CGRect frame=self.ImageView.frame;
frame.origin.y=y;
frame.size.height=-y;
self.ImageView.frame=frame;
}
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return arr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellID = @"cellID";
IIITableViewController *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) {
cell = [[IIITableViewController alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
NSString *str = [arr objectAtIndex:indexPath.row];
NSArray *dataArr = [dic objectForKey:str];
cell.imgView.image = [UIImage imageNamed:[dataArr objectAtIndex:0]];
cell.titleLabel.text = [arr objectAtIndex:indexPath.row];
cell.subTitleLabel.text = dataArr[1];
cell.timeLabel.text = dataArr[2];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end