- (void)viewDidLoad {
[selfuidata];
dataSource = [[NSMutableArray alloc]init];
for(NSUIntegeri =0; i<20; i++) {
[dataSource addObject:[NSString stringWithFormat:@"%ld",i]];
}
self.view.backgroundColor = [UIColor blackColor];
[super viewDidLoad];
[self initTable];
}
-(void)initTable{
nearbyTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 45, self.view.frame.size.width, self.view.frame.size.height-64) style:UITableViewStylePlain];
nearbyTable.delegate = self;
nearbyTable.dataSource = self;
nearbyTable.rowHeight=80;
[self.view addSubview:nearbyTable];
//nearbyTable.tableFooterView = [UIView new];
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{
returntabarr.count;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
staticNSString*identifer =@"cell";
UITableViewCell *cell = [nearbyTable dequeueReusableCellWithIdentifier:identifer];
if(cell==nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifer];
}
Hqxw*one =tabarr[indexPath.row];
cell.textLabel.text=one.title;
cell.detailTextLabel.text =one.releaseDate;
//[cell.imageView sd_setImageWithURL:[NSURL URLWithString:one.imageUrl] placeholderImage:[UIImage imageNamed:@""]];
//网址字符串
[cell.imageViewsd_setImageWithURL:[NSURLURLWithString:one.imageUrl]placeholderImage:[UIImageimageNamed:@"03.png"]completed:^(UIImage*image,NSError*error,SDImageCacheTypecacheType,NSURL*imageURL) {
CGSizeitemSize =CGSizeMake(60,50);
UIGraphicsBeginImageContextWithOptions(itemSize, NO, 0.0);
CGRectimageRect =CGRectMake(0,0,60,50);
[imagedrawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}];
returncell;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)uidata{
[[[NetworkDataalloc]init]GET:STUDENT_URLparams:nilcompletion:^(iddata,BOOLsucess) {
NSMutableArray* arr = [dataobjectForKey:@"data"];
tabarr=[[NSMutableArrayalloc]init];
for(NSDictionary*dicinarr) {
Hqxw*one =[[Hqxwalloc]init];
one.title= [dicobjectForKey:@"title"];
one.imageUrl= [dicobjectForKey:@"imageUrl"];
one.releaseDate= [dicobjectForKey:@"releaseDate"];
[tabarraddObject:one];
}
[nearbyTablereloadData];
}];
}
网友评论